data.table

Fast and Memory Efficient Data Manipulation


“Sometimes I’ll start a sentence and I don’t even know where it’s going. I just hope I find it along the way.”


“I am fast. To give you a reference point, I am somewhere between a snake and a mongoose… and a panther.”

Why data.table?

  1. Concise syntax: fast to type, fast to read – “Me think, why waste time say lot word when few word do trick.”
  1. Fast speed: optimized C code under the hood – “I am faster than 80 percent of all snakes.”
  1. Memory efficient: modify by reference – “Whenever I’m about to do something, I think, “would an idiot do that?” And if they would, I do not do that thing.”

Why data.table?

  1. Careful API lifecycle management: stable, backward compatible – “I’m not superstitious, but I am a little stitious.”
  1. Community: active development and support – “Would I rather be feared or loved? Easy. Both. I want people to be afraid of how much they love me.”
  1. Feature rich: comprehensive data manipulation toolkit – “Bears, beets, Battlestar Galactica.”

Data for Examples

Loading PUMS Data

Preview to next section with Jonathon about arrow:

library(data.table)
library(dplyr)
library(arrow)

# Preview into next section: Load multiple states and years using arrow
pums <- open_dataset(here::here("data/person")) |>
  filter(year >= 2020, location %in% c("ca", "tx", "ny")) |>
  collect()
setDT(pums)

Loading PUMS Data

pums[, 1:5]
         SPORDER            RT      SERIALNO   PUMA          ST
           <int>        <fctr>        <char> <char>      <char>
      1:       1 Person Record 2021HU0896827  00904 New York/NY
      2:       2 Person Record 2021HU0896827  00904 New York/NY
      3:       3 Person Record 2021HU0896827  00904 New York/NY
      4:       4 Person Record 2021HU0896827  00904 New York/NY
      5:       5 Person Record 2021HU0896827  00904 New York/NY
     ---                                                       
1735551:       1 Person Record 2022HU0609672  04611    Texas/TX
1735552:       2 Person Record 2022HU0609672  04611    Texas/TX
1735553:       3 Person Record 2022HU0609672  04611    Texas/TX
1735554:       1 Person Record 2022HU0609675  04302    Texas/TX
1735555:       2 Person Record 2022HU0609675  04302    Texas/TX
names(pums)
  [1] "SPORDER"   "RT"        "SERIALNO"  "PUMA"      "ST"        "ADJUST"   
  [7] "PWGTP"     "AGEP"      "CIT"       "COW"       "DDRS"      "DEYE"     
 [13] "DOUT"      "DPHY"      "DREM"      "DWRK"      "ENG"       "FER"      
 [19] "GCL"       "GCM"       "GCR"       "INTP"      "JWMNP"     "JWRIP"    
 [25] "JWTR"      "LANX"      "MAR"       "MIG"       "MIL"       "MILY"     
 [31] "MLPA"      "MLPB"      "MLPC"      "MLPD"      "MLPE"      "MLPF"     
 [37] "MLPG"      "MLPH"      "MLPI"      "MLPJ"      "MLPK"      "NWAB"     
 [43] "NWAV"      "NWLA"      "NWLK"      "NWRE"      "OIP"       "PAP"      
 [49] "REL"       "RETP"      "SCH"       "SCHG"      "SCHL"      "SEMP"     
 [55] "SEX"       "SSIP"      "SSP"       "WAGP"      "WKHP"      "WKL"      
 [61] "WKW"       "YOEP"      "UWRK"      "ANC"       "ANC1P"     "ANC2P"    
 [67] "DECADE"    "DRIVESP"   "DS"        "ESP"       "ESR"       "HISP"     
 [73] "INDP"      "JWAP"      "JWDP"      "LANP"      "MIGPUMA"   "MIGSP"    
 [79] "MSP"       "NAICSP"    "NATIVITY"  "OC"        "OCCP"      "PAOC"     
 [85] "PERNP"     "PINCP"     "POBP"      "POVPIP"    "POWPUMA"   "POWSP"    
 [91] "QTRBIR"    "RAC1P"     "RAC2P"     "RAC3P"     "RACAIAN"   "RACASN"   
 [97] "RACBLK"    "RACNHPI"   "RACNUM"    "RACSOR"    "RACWHT"    "RC"       
[103] "SFN"       "SFR"       "SOCP"      "VPS"       "WAOB"      "FAGEP"    
[109] "FANCP"     "FCITP"     "FCOWP"     "FDDRSP"    "FDEYEP"    "FDOUTP"   
[115] "FDPHYP"    "FDREMP"    "FDWRKP"    "FENGP"     "FESRP"     "FFERP"    
[121] "FGCLP"     "FGCMP"     "FGCRP"     "FHISP"     "FINDP"     "FINTP"    
[127] "FJWDP"     "FJWMNP"    "FJWRIP"    "FJWTRP"    "FLANP"     "FLANXP"   
[133] "FMARP"     "FMIGP"     "FMIGSP"    "FMILPP"    "FMILSP"    "FMILYP"   
[139] "FOCCP"     "FOIP"      "FPAP"      "FPOBP"     "FPOWSP"    "FRACP"    
[145] "FRELP"     "FRETP"     "FSCHGP"    "FSCHLP"    "FSCHP"     "FSEMP"    
[151] "FSEXP"     "FSSIP"     "FSSP"      "FWAGP"     "FWKHP"     "FWKLP"    
[157] "FWKWP"     "FYOEP"     "PWGTP1"    "PWGTP2"    "PWGTP3"    "PWGTP4"   
[163] "PWGTP5"    "PWGTP6"    "PWGTP7"    "PWGTP8"    "PWGTP9"    "PWGTP10"  
[169] "PWGTP11"   "PWGTP12"   "PWGTP13"   "PWGTP14"   "PWGTP15"   "PWGTP16"  
[175] "PWGTP17"   "PWGTP18"   "PWGTP19"   "PWGTP20"   "PWGTP21"   "PWGTP22"  
[181] "PWGTP23"   "PWGTP24"   "PWGTP25"   "PWGTP26"   "PWGTP27"   "PWGTP28"  
[187] "PWGTP29"   "PWGTP30"   "PWGTP31"   "PWGTP32"   "PWGTP33"   "PWGTP34"  
[193] "PWGTP35"   "PWGTP36"   "PWGTP37"   "PWGTP38"   "PWGTP39"   "PWGTP40"  
[199] "PWGTP41"   "PWGTP42"   "PWGTP43"   "PWGTP44"   "PWGTP45"   "PWGTP46"  
[205] "PWGTP47"   "PWGTP48"   "PWGTP49"   "PWGTP50"   "PWGTP51"   "PWGTP52"  
[211] "PWGTP53"   "PWGTP54"   "PWGTP55"   "PWGTP56"   "PWGTP57"   "PWGTP58"  
[217] "PWGTP59"   "PWGTP60"   "PWGTP61"   "PWGTP62"   "PWGTP63"   "PWGTP64"  
[223] "PWGTP65"   "PWGTP66"   "PWGTP67"   "PWGTP68"   "PWGTP69"   "PWGTP70"  
[229] "PWGTP71"   "PWGTP72"   "PWGTP73"   "PWGTP74"   "PWGTP75"   "PWGTP76"  
[235] "PWGTP77"   "PWGTP78"   "PWGTP79"   "PWGTP80"   "NOP"       "ADJINC"   
[241] "CITWP"     "DEAR"      "DRAT"      "DRATX"     "HINS1"     "HINS2"    
[247] "HINS3"     "HINS4"     "HINS5"     "HINS6"     "HINS7"     "MARHD"    
[253] "MARHM"     "MARHT"     "MARHW"     "MARHYP"    "DIS"       "HICOV"    
[259] "PRIVCOV"   "PUBCOV"    "FCITWP"    "FDEARP"    "FDRATP"    "FDRATXP"  
[265] "FHINS1P"   "FHINS2P"   "FHINS3P"   "FHINS4P"   "FHINS5P"   "FHINS6P"  
[271] "FHINS7P"   "FMARHDP"   "FMARHMP"   "FMARHTP"   "FMARHWP"   "FMARHYP"  
[277] "WRK"       "FOD1P"     "FOD2P"     "SCIENGP"   "SCIENGRLP" "FFODP"    
[283] "FHINS3C"   "FHINS4C"   "FHINS5C"   "RELP"      "FWRKP"     "FDISP"    
[289] "FPERNP"    "FPINCP"    "FPRIVCOVP" "FPUBCOVP"  "RACNH"     "RACPI"    
[295] "SSPA"      "MLPCD"     "MLPFG"     "FHICOVP"   "DIVISION"  "REGION"   
[301] "HIMRKS"    "JWTRNS"    "RELSHIPP"  "WKWN"      "FHIMRKSP"  "FJWTRNSP" 
[307] "FRELSHIPP" "FWKWNP"    "MLPIK"     "year"      "location" 

1. Concise Syntax

“why waste time say lot word when few word do trick.”


1. Concise Syntax

Fast to type, fast to read

# Base R approach
pums_df <- as.data.frame(pums)
subset_data <- pums_df[pums$ST == "California/CA" & pums$year == 2022, ]
age_groups <- ifelse(subset_data$AGEP < 18, "Under 18",
                    ifelse(subset_data$AGEP < 65, "18-64", "65+"))
base_result <- aggregate(subset_data$PWGTP, by = list(age_group = age_groups), FUN = sum)

# data.table approach
pums[, age_groups := fcase(AGEP < 18, "Under 18", AGEP < 65, "18-64", default = "65+")]
dt_result <- pums[
  year == 2022 & ST == "California/CA", 
  .(total_pop = sum(PWGTP)), 
  by = age_groups
]
base_result
  age_group        x
1     18-64 24372342
2       65+  6165865
3  Under 18  8491135
dt_result
   age_groups total_pop
       <char>     <int>
1:      18-64  24372342
2:        65+   6165865
3:   Under 18   8491135

Fill in the Blank

We want to take the pums data.table and select the SCHL, SEX, ST, and AGEP.

dt_subset <- pums[,

]

Fill in the Blank

We want to take the pums data.table and select the SCHL, SEX, ST, and AGEP.

dt_subset <- pums[,
  .(SCHL, SEX, ST, AGEP)
]

Fill in the Blank

We want to subset to those in “ny” based on our location variable, group by age_groups and year, and get the proportion of those in the “Civilian employed, at work” based on the ESR variable.

dt_ny <- pums[



]

Fill in the Blank

We want to subset to those in “ny” based on our location variable, group by age_groups and year, and get the proportion of those in the “Civilian employed, at work” based on the ESR variable.

dt_ny <- pums[
  location == "ny",
  .(employed = mean(ESR == "Civilian employed, at work", na.rm = TRUE)),
  by = .(age_groups, year)
]

What will this do?

HINSx are insurance types WAGP income (wages/salary) last 12 months

pums[, ins_type := fcase(
  HINS1 == TRUE, "employer", 
  HINS2 == TRUE, "direct", 
  HINS3 == TRUE, "Medicare", 
  HINS4 == TRUE, "Medicaid",
  HINS5 == TRUE | HINS6 == TRUE | HINS7 == TRUE, "other",
  default = "no insurance")
]
pums[, .(avg_income = mean(WAGP, na.rm = TRUE)), by = ins_type]

What will this do?

HINSx are insurance types WAGP income (wages/salary) last 12 months

pums[, ins_type := fcase(
  HINS1 == TRUE, "employer", 
  HINS2 == TRUE, "direct", 
  HINS3 == TRUE, "Medicare", 
  HINS4 == TRUE, "Medicaid",
  HINS5 == TRUE | HINS6 == TRUE | HINS7 == TRUE, "other",
  default = "no insurance")
]
pums[, .(avg_income = mean(WAGP, na.rm = TRUE)), by = ins_type]
       ins_type avg_income
         <char>      <num>
1:       direct  20805.087
2:     employer  57418.563
3:     Medicare   6044.857
4:     Medicaid  10794.296
5: no insurance  18047.548
6:        other  30429.201

2. Fast Speed

“I am faster than 80 percent of all snakes.”

Benchmarking is difficult

# Benchmarking aggregation operations
microbenchmark::microbenchmark(
  # data.table
  pums[, .(total_pop = sum(PWGTP)), by = .(ST, year)],
  
  # dplyr
  pums_df |> 
    group_by(ST, year) |> 
    summarise(total_pop = sum(PWGTP), .groups = "drop"),

  times = 10
)
Unit: milliseconds
                                                                                  expr
                                   pums[, .(total_pop = sum(PWGTP)), by = .(ST, year)]
 summarise(group_by(pums_df, ST, year), total_pop = sum(PWGTP),      .groups = "drop")
      min       lq     mean   median       uq      max neval
 10.42335 10.62146 11.65538 11.32906 12.71615 13.73602    10
 20.63649 21.47834 22.54786 22.54221 23.03208 26.18965    10

2. Fast Speed

# Benchmarking aggregation operations
microbenchmark::microbenchmark(
  # data.table
  pums[, .(total_pop = sum(PWGTP)), keyby = .(ST, year)],
  
  # dplyr
  pums_df |> 
    group_by(ST, year) |> 
    summarise(total_pop = sum(PWGTP), .groups = "drop") |> 
    arrange(ST, year),

  times = 10
)
Unit: milliseconds
                                                                                                     expr
                                                   pums[, .(total_pop = sum(PWGTP)), keyby = .(ST, year)]
 arrange(summarise(group_by(pums_df, ST, year), total_pop = sum(PWGTP),      .groups = "drop"), ST, year)
      min       lq     mean   median       uq      max neval
 36.42801 36.74305 37.01181 37.02540 37.14883 38.13676    10
 22.63918 22.81043 24.58615 23.80175 27.15233 28.06593    10

3. Memory Efficient

“Whenever I’m about to do something, I think, “would an idiot do that?” And if they would, I do not do that thing.”


Quick History Lesson on Shallow/Deep Copies

# Create a copy (memory inefficient)
pums_nocopy <- pums

# Modify by reference (memory efficient)
pums[, age_decade := floor(AGEP / 10) * 10]

# shows up in pums_nocopy
pums_nocopy[, .(age_decade)]
         age_decade
              <num>
      1:         60
      2:         40
      3:         30
      4:         20
      5:         20
     ---           
1735551:         50
1735552:         60
1735553:         20
1735554:         60
1735555:         60
lobstr::ref(pums)
█ [1:0x10ceb7800] <dt[,314]> 
├─SPORDER = [2:0x324f88000] <int> 
├─RT = [3:0x325cc8000] <fct> 
├─SERIALNO = [4:0x11e900000] <chr> 
├─PUMA = [5:0x12b000000] <chr> 
├─ST = [6:0x138000000] <chr> 
├─ADJUST = [7:0x147118000] <int> 
├─PWGTP = [8:0x330008000] <int> 
├─AGEP = [9:0x330d48000] <int> 
├─CIT = [10:0x331a88000] <fct> 
├─COW = [11:0x3327c8000] <fct> 
├─DDRS = [12:0x150a90000] <lgl> 
├─DEYE = [13:0x178030000] <lgl> 
├─DOUT = [14:0x1786d0000] <lgl> 
├─DPHY = [15:0x178d70000] <lgl> 
├─DREM = [16:0x110390000] <lgl> 
├─DWRK = [17:0x310008000] <lgl> 
├─ENG = [18:0x333508000] <fct> 
├─FER = [19:0x110a30000] <lgl> 
├─GCL = [20:0x148110000] <lgl> 
├─GCM = [21:0x334248000] <fct> 
├─GCR = [22:0x3106a8000] <lgl> 
├─INTP = [23:0x334f88000] <int> 
├─JWMNP = [24:0x335cc8000] <int> 
├─JWRIP = [25:0x139a80000] <chr> 
├─JWTR = [26:0x13d800000] <chr> 
├─LANX = [27:0x310d48000] <lgl> 
├─MAR = [28:0x336a08000] <fct> 
├─MIG = [29:0x3113e8000] <lgl> 
├─MIL = [30:0x337748000] <fct> 
├─MILY = [31:0x3386a8000] <fct> 
├─MLPA = [32:0x3080c8000] <lgl> 
├─MLPB = [33:0x140db8000] <lgl> 
├─MLPC = [34:0x179410000] <lgl> 
├─MLPD = [35:0x308768000] <lgl> 
├─MLPE = [36:0x308e08000] <lgl> 
├─MLPF = [37:0x3094a8000] <lgl> 
├─MLPG = [38:0x3000a0000] <lgl> 
├─MLPH = [39:0x131428000] <lgl> 
├─MLPI = [40:0x179ab0000] <lgl> 
├─MLPJ = [41:0x17a150000] <lgl> 
├─MLPK = [42:0x17a7f0000] <lgl> 
├─NWAB = [43:0x17ae90000] <lgl> 
├─NWAV = [44:0x3393e8000] <fct> 
├─NWLA = [45:0x170070000] <lgl> 
├─NWLK = [46:0x170710000] <lgl> 
├─NWRE = [47:0x151130000] <lgl> 
├─OIP = [48:0x33a128000] <int> 
├─PAP = [49:0x33ae68000] <int> 
├─REL = [50:0x13f280000] <chr> 
├─RETP = [51:0x33bba8000] <int> 
├─SCH = [52:0x300740000] <lgl> 
├─SCHG = [53:0x158d40000] <chr> 
├─SCHL = [54:0x15a7c0000] <chr> 
├─SEMP = [55:0x14afe8000] <int> 
├─SEX = [56:0x14bd28000] <fct> 
├─SSIP = [57:0x14ca68000] <int> 
├─SSP = [58:0x14d7a8000] <int> 
├─WAGP = [59:0x154630000] <int> 
├─WKHP = [60:0x155370000] <int> 
├─WKL = [61:0x1560b0000] <fct> 
├─WKW = [62:0x156df0000] <fct> 
├─YOEP = [63:0x161948000] <chr> 
├─UWRK = [64:0x141458000] <lgl> 
├─ANC = [65:0x340008000] <fct> 
├─ANC1P = [66:0x1633c8000] <chr> 
├─ANC2P = [67:0x164e48000] <chr> 
├─DECADE = [68:0x340d48000] <fct> 
├─DRIVESP = [69:0x341a88000] <fct> 
├─DS = [70:0x141af8000] <lgl> 
├─ESP = [71:0x3427c8000] <fct> 
├─ESR = [72:0x343508000] <fct> 
├─HISP = [73:0x1668c8000] <chr> 
├─INDP = [74:0x168348000] <chr> 
├─JWAP = [75:0x348000000] <chr> 
├─JWDP = [76:0x349a80000] <chr> 
├─LANP = [77:0x34b500000] <chr> 
├─MIGPUMA = [78:0x14e4e8000] <fct> 
├─MIGSP = [79:0x34cf80000] <chr> 
├─MSP = [80:0x14f228000] <fct> 
├─NAICSP = [81:0x34ea00000] <chr> 
├─NATIVITY = [82:0x358008000] <fct> 
├─OC = [83:0x142198000] <lgl> 
├─OCCP = [84:0x350480000] <chr> 
├─PAOC = [85:0x358d48000] <fct> 
├─PERNP = [86:0x359a88000] <int> 
├─PINCP = [87:0x35a7c8000] <int> 
├─POBP = [88:0x351f00000] <chr> 
├─POVPIP = [89:0x35b508000] <int> 
├─POWPUMA = [90:0x35c248000] <fct> 
├─POWSP = [91:0x353980000] <chr> 
├─QTRBIR = [92:0x35cf88000] <fct> 
├─RAC1P = [93:0x35dcc8000] <fct> 
├─RAC2P = [94:0x355400000] <chr> 
├─RAC3P = [95:0x356e80000] <chr> 
├─RACAIAN = [96:0x120788000] <lgl> 
├─RACASN = [97:0x120e28000] <lgl> 
├─RACBLK = [98:0x311a88000] <lgl> 
├─RACNHPI = [99:0x312128000] <lgl> 
├─RACNUM = [100:0x344248000] <int> 
├─RACSOR = [101:0x1517d0000] <lgl> 
├─RACWHT = [102:0x3127c8000] <lgl> 
├─RC = [103:0x312e68000] <lgl> 
├─SFN = [104:0x344f88000] <fct> 
├─SFR = [105:0x345cc8000] <fct> 
├─SOCP = [106:0x360d40000] <chr> 
├─VPS = [107:0x3627c0000] <chr> 
├─WAOB = [108:0x346a08000] <fct> 
├─FAGEP = [109:0x151e70000] <lgl> 
├─FANCP = [110:0x152510000] <lgl> 
├─FCITP = [111:0x152bb0000] <lgl> 
├─FCOWP = [112:0x153250000] <lgl> 
├─FDDRSP = [113:0x142838000] <lgl> 
├─FDEYEP = [114:0x142ed8000] <lgl> 
├─FDOUTP = [115:0x300de0000] <lgl> 
├─FDPHYP = [116:0x131ac8000] <lgl> 
├─FDREMP = [117:0x309b48000] <lgl> 
├─FDWRKP = [118:0x30a1e8000] <lgl> 
├─FENGP = [119:0x30a888000] <lgl> 
├─FESRP = [120:0x1214c8000] <lgl> 
├─FFERP = [121:0x121b68000] <lgl> 
├─FGCLP = [122:0x143578000] <lgl> 
├─FGCMP = [123:0x143c18000] <lgl> 
├─FGCRP = [124:0x1442b8000] <lgl> 
├─FHISP = [125:0x144958000] <lgl> 
├─FINDP = [126:0x144ff8000] <lgl> 
├─FINTP = [127:0x145698000] <lgl> 
├─FJWDP = [128:0x145d38000] <lgl> 
├─FJWMNP = [129:0x1463d8000] <lgl> 
├─FJWRIP = [130:0x1110d0000] <lgl> 
├─FJWTRP = [131:0x132168000] <lgl> 
├─FLANP = [132:0x318008000] <lgl> 
├─FLANXP = [133:0x1487b0000] <lgl> 
├─FMARP = [134:0x148e50000] <lgl> 
├─FMIGP = [135:0x1494f0000] <lgl> 
├─FMIGSP = [136:0x313508000] <lgl> 
├─FMILPP = [137:0x132808000] <lgl> 
├─FMILSP = [138:0x30af28000] <lgl> 
├─FMILYP = [139:0x301480000] <lgl> 
├─FOCCP = [140:0x111770000] <lgl> 
├─FOIP = [141:0x111e10000] <lgl> 
├─FPAP = [142:0x1124b0000] <lgl> 
├─FPOBP = [143:0x122208000] <lgl> 
├─FPOWSP = [144:0x313ba8000] <lgl> 
├─FRACP = [145:0x17b530000] <lgl> 
├─FRELP = [146:0x314248000] <lgl> 
├─FRETP = [147:0x1538f0000] <lgl> 
├─FSCHGP = [148:0x153f90000] <lgl> 
├─FSCHLP = [149:0x3148e8000] <lgl> 
├─FSCHP = [150:0x314f88000] <lgl> 
├─FSEMP = [151:0x170db0000] <lgl> 
├─FSEXP = [152:0x171450000] <lgl> 
├─FSSIP = [153:0x301b20000] <lgl> 
├─FSSP = [154:0x132ea8000] <lgl> 
├─FWAGP = [155:0x133548000] <lgl> 
├─FWKHP = [156:0x315628000] <lgl> 
├─FWKLP = [157:0x3021c0000] <lgl> 
├─FWKWP = [158:0x315cc8000] <lgl> 
├─FYOEP = [159:0x316368000] <lgl> 
├─PWGTP1 = [160:0x347748000] <int> 
├─PWGTP2 = [161:0x3686a8000] <int> 
├─PWGTP3 = [162:0x3693e8000] <int> 
├─PWGTP4 = [163:0x36a128000] <int> 
├─PWGTP5 = [164:0x36ae68000] <int> 
├─PWGTP6 = [165:0x36bba8000] <int> 
├─PWGTP7 = [166:0x36c8e8000] <int> 
├─PWGTP8 = [167:0x36d628000] <int> 
├─PWGTP9 = [168:0x36e368000] <int> 
├─PWGTP10 = [169:0x36f0a8000] <int> 
├─PWGTP11 = [170:0x370008000] <int> 
├─PWGTP12 = [171:0x370d48000] <int> 
├─PWGTP13 = [172:0x371a88000] <int> 
├─PWGTP14 = [173:0x3727c8000] <int> 
├─PWGTP15 = [174:0x373508000] <int> 
├─PWGTP16 = [175:0x374248000] <int> 
├─PWGTP17 = [176:0x374f88000] <int> 
├─PWGTP18 = [177:0x375cc8000] <int> 
├─PWGTP19 = [178:0x376a08000] <int> 
├─PWGTP20 = [179:0x377748000] <int> 
├─PWGTP21 = [180:0x3786a8000] <int> 
├─PWGTP22 = [181:0x3793e8000] <int> 
├─PWGTP23 = [182:0x37a128000] <int> 
├─PWGTP24 = [183:0x37ae68000] <int> 
├─PWGTP25 = [184:0x37bba8000] <int> 
├─PWGTP26 = [185:0x37c8e8000] <int> 
├─PWGTP27 = [186:0x37d628000] <int> 
├─PWGTP28 = [187:0x37e368000] <int> 
├─PWGTP29 = [188:0x37f0a8000] <int> 
├─PWGTP30 = [189:0x380008000] <int> 
├─PWGTP31 = [190:0x380d48000] <int> 
├─PWGTP32 = [191:0x381a88000] <int> 
├─PWGTP33 = [192:0x3827c8000] <int> 
├─PWGTP34 = [193:0x383508000] <int> 
├─PWGTP35 = [194:0x384248000] <int> 
├─PWGTP36 = [195:0x384f88000] <int> 
├─PWGTP37 = [196:0x385cc8000] <int> 
├─PWGTP38 = [197:0x386a08000] <int> 
├─PWGTP39 = [198:0x387748000] <int> 
├─PWGTP40 = [199:0x3886a8000] <int> 
├─PWGTP41 = [200:0x3893e8000] <int> 
├─PWGTP42 = [201:0x38a128000] <int> 
├─PWGTP43 = [202:0x38ae68000] <int> 
├─PWGTP44 = [203:0x38bba8000] <int> 
├─PWGTP45 = [204:0x38c8e8000] <int> 
├─PWGTP46 = [205:0x38d628000] <int> 
├─PWGTP47 = [206:0x38e368000] <int> 
├─PWGTP48 = [207:0x38f0a8000] <int> 
├─PWGTP49 = [208:0x390008000] <int> 
├─PWGTP50 = [209:0x390d48000] <int> 
├─PWGTP51 = [210:0x391a88000] <int> 
├─PWGTP52 = [211:0x3927c8000] <int> 
├─PWGTP53 = [212:0x393508000] <int> 
├─PWGTP54 = [213:0x394248000] <int> 
├─PWGTP55 = [214:0x394f88000] <int> 
├─PWGTP56 = [215:0x395cc8000] <int> 
├─PWGTP57 = [216:0x35ea08000] <int> 
├─PWGTP58 = [217:0x35f748000] <int> 
├─PWGTP59 = [218:0x3986a8000] <int> 
├─PWGTP60 = [219:0x3993e8000] <int> 
├─PWGTP61 = [220:0x39a128000] <int> 
├─PWGTP62 = [221:0x39ae68000] <int> 
├─PWGTP63 = [222:0x39bba8000] <int> 
├─PWGTP64 = [223:0x39c8e8000] <int> 
├─PWGTP65 = [224:0x39d628000] <int> 
├─PWGTP66 = [225:0x39e368000] <int> 
├─PWGTP67 = [226:0x39f0a8000] <int> 
├─PWGTP68 = [227:0x3a0008000] <int> 
├─PWGTP69 = [228:0x3a0d48000] <int> 
├─PWGTP70 = [229:0x3a1a88000] <int> 
├─PWGTP71 = [230:0x3a27c8000] <int> 
├─PWGTP72 = [231:0x3a3508000] <int> 
├─PWGTP73 = [232:0x3a4248000] <int> 
├─PWGTP74 = [233:0x3a4f88000] <int> 
├─PWGTP75 = [234:0x3a5cc8000] <int> 
├─PWGTP76 = [235:0x3a6a08000] <int> 
├─PWGTP77 = [236:0x3a7748000] <int> 
├─PWGTP78 = [237:0x3a86a8000] <int> 
├─PWGTP79 = [238:0x3a93e8000] <int> 
├─PWGTP80 = [239:0x3aa128000] <int> 
├─NOP = [240:0x3aae68000] <fct> 
├─ADJINC = [241:0x364240000] <dbl> 
├─CITWP = [242:0x365cc0000] <chr> 
├─DEAR = [243:0x30b5c8000] <lgl> 
├─DRAT = [244:0x3abba8000] <fct> 
├─DRATX = [245:0x133be8000] <lgl> 
├─HINS1 = [246:0x134288000] <lgl> 
├─HINS2 = [247:0x134928000] <lgl> 
├─HINS3 = [248:0x134fc8000] <lgl> 
├─HINS4 = [249:0x135668000] <lgl> 
├─HINS5 = [250:0x135d08000] <lgl> 
├─HINS6 = [251:0x1363a8000] <lgl> 
├─HINS7 = [252:0x136a48000] <lgl> 
├─MARHD = [253:0x1370e8000] <lgl> 
├─MARHM = [254:0x137788000] <lgl> 
├─MARHT = [255:0x3ac8e8000] <fct> 
├─MARHW = [256:0x320008000] <lgl> 
├─MARHYP = [257:0x3b0000000] <chr> 
├─DIS = [258:0x3206a8000] <lgl> 
├─HICOV = [259:0x320d48000] <lgl> 
├─PRIVCOV = [260:0x3213e8000] <lgl> 
├─PUBCOV = [261:0x321a88000] <lgl> 
├─FCITWP = [262:0x322128000] <lgl> 
├─FDEARP = [263:0x3227c8000] <lgl> 
├─FDRATP = [264:0x322e68000] <lgl> 
├─FDRATXP = [265:0x323508000] <lgl> 
├─FHINS1P = [266:0x323ba8000] <lgl> 
├─FHINS2P = [267:0x324248000] <lgl> 
├─FHINS3P = [268:0x149b90000] <lgl> 
├─FHINS4P = [269:0x30bc68000] <lgl> 
├─FHINS5P = [270:0x30c308000] <lgl> 
├─FHINS6P = [271:0x30c9a8000] <lgl> 
├─FHINS7P = [272:0x302860000] <lgl> 
├─FMARHDP = [273:0x30d048000] <lgl> 
├─FMARHMP = [274:0x316a08000] <lgl> 
├─FMARHTP = [275:0x3170a8000] <lgl> 
├─FMARHWP = [276:0x17bbd0000] <lgl> 
├─FMARHYP = [277:0x17c270000] <lgl> 
├─WRK = [278:0x17c910000] <lgl> 
├─FOD1P = [279:0x3b1a80000] <chr> 
├─FOD2P = [280:0x3b3500000] <chr> 
├─SCIENGP = [281:0x171af0000] <lgl> 
├─SCIENGRLP = [282:0x172190000] <lgl> 
├─FFODP = [283:0x112b50000] <lgl> 
├─FHINS3C = [284:0x122f48000] <fct> 
├─FHINS4C = [285:0x123c88000] <fct> 
├─FHINS5C = [286:0x1249c8000] <fct> 
├─RELP = [287:0x3b4f80000] <chr> 
├─FWRKP = [288:0x17cfb0000] <lgl> 
├─FDISP = [289:0x17d650000] <lgl> 
├─FPERNP = [290:0x17dcf0000] <lgl> 
├─FPINCP = [291:0x17e390000] <lgl> 
├─FPRIVCOVP = [292:0x317748000] <lgl> 
├─FPUBCOVP = [293:0x328008000] <lgl> 
├─RACNH = [294:0x146a78000] <lgl> 
├─RACPI = [295:0x302f00000] <lgl> 
├─SSPA = [296:0x125708000] <fct> 
├─MLPCD = [297:0x3186a8000] <lgl> 
├─MLPFG = [298:0x318d48000] <lgl> 
├─FHICOVP = [299:0x3193e8000] <lgl> 
├─DIVISION = [300:0x126448000] <fct> 
├─REGION = [301:0x127188000] <fct> 
├─HIMRKS = [302:0x3b8008000] <fct> 
├─JWTRNS = [303:0x3b6a00000] <chr> 
├─RELSHIPP = [304:0x3c0d40000] <chr> 
├─WKWN = [305:0x3b8d48000] <int> 
├─FHIMRKSP = [306:0x17ea30000] <lgl> 
├─FJWTRNSP = [307:0x3248e8000] <lgl> 
├─FRELSHIPP = [308:0x1228a8000] <lgl> 
├─FWKWNP = [309:0x319a88000] <lgl> 
├─MLPIK = [310:0x14a230000] <lgl> 
├─year = [311:0x3b9a88000] <int> 
├─location = [312:0x3c27c0000] <chr> 
├─age_groups = [313:0x34a7c0000] <chr> 
├─ins_type = [314:0x34c240000] <chr> 
└─age_decade = [315:0x366a00000] <dbl> 
lobstr::ref(pums_nocopy)
█ [1:0x10ceb7800] <dt[,314]> 
├─SPORDER = [2:0x324f88000] <int> 
├─RT = [3:0x325cc8000] <fct> 
├─SERIALNO = [4:0x11e900000] <chr> 
├─PUMA = [5:0x12b000000] <chr> 
├─ST = [6:0x138000000] <chr> 
├─ADJUST = [7:0x147118000] <int> 
├─PWGTP = [8:0x330008000] <int> 
├─AGEP = [9:0x330d48000] <int> 
├─CIT = [10:0x331a88000] <fct> 
├─COW = [11:0x3327c8000] <fct> 
├─DDRS = [12:0x150a90000] <lgl> 
├─DEYE = [13:0x178030000] <lgl> 
├─DOUT = [14:0x1786d0000] <lgl> 
├─DPHY = [15:0x178d70000] <lgl> 
├─DREM = [16:0x110390000] <lgl> 
├─DWRK = [17:0x310008000] <lgl> 
├─ENG = [18:0x333508000] <fct> 
├─FER = [19:0x110a30000] <lgl> 
├─GCL = [20:0x148110000] <lgl> 
├─GCM = [21:0x334248000] <fct> 
├─GCR = [22:0x3106a8000] <lgl> 
├─INTP = [23:0x334f88000] <int> 
├─JWMNP = [24:0x335cc8000] <int> 
├─JWRIP = [25:0x139a80000] <chr> 
├─JWTR = [26:0x13d800000] <chr> 
├─LANX = [27:0x310d48000] <lgl> 
├─MAR = [28:0x336a08000] <fct> 
├─MIG = [29:0x3113e8000] <lgl> 
├─MIL = [30:0x337748000] <fct> 
├─MILY = [31:0x3386a8000] <fct> 
├─MLPA = [32:0x3080c8000] <lgl> 
├─MLPB = [33:0x140db8000] <lgl> 
├─MLPC = [34:0x179410000] <lgl> 
├─MLPD = [35:0x308768000] <lgl> 
├─MLPE = [36:0x308e08000] <lgl> 
├─MLPF = [37:0x3094a8000] <lgl> 
├─MLPG = [38:0x3000a0000] <lgl> 
├─MLPH = [39:0x131428000] <lgl> 
├─MLPI = [40:0x179ab0000] <lgl> 
├─MLPJ = [41:0x17a150000] <lgl> 
├─MLPK = [42:0x17a7f0000] <lgl> 
├─NWAB = [43:0x17ae90000] <lgl> 
├─NWAV = [44:0x3393e8000] <fct> 
├─NWLA = [45:0x170070000] <lgl> 
├─NWLK = [46:0x170710000] <lgl> 
├─NWRE = [47:0x151130000] <lgl> 
├─OIP = [48:0x33a128000] <int> 
├─PAP = [49:0x33ae68000] <int> 
├─REL = [50:0x13f280000] <chr> 
├─RETP = [51:0x33bba8000] <int> 
├─SCH = [52:0x300740000] <lgl> 
├─SCHG = [53:0x158d40000] <chr> 
├─SCHL = [54:0x15a7c0000] <chr> 
├─SEMP = [55:0x14afe8000] <int> 
├─SEX = [56:0x14bd28000] <fct> 
├─SSIP = [57:0x14ca68000] <int> 
├─SSP = [58:0x14d7a8000] <int> 
├─WAGP = [59:0x154630000] <int> 
├─WKHP = [60:0x155370000] <int> 
├─WKL = [61:0x1560b0000] <fct> 
├─WKW = [62:0x156df0000] <fct> 
├─YOEP = [63:0x161948000] <chr> 
├─UWRK = [64:0x141458000] <lgl> 
├─ANC = [65:0x340008000] <fct> 
├─ANC1P = [66:0x1633c8000] <chr> 
├─ANC2P = [67:0x164e48000] <chr> 
├─DECADE = [68:0x340d48000] <fct> 
├─DRIVESP = [69:0x341a88000] <fct> 
├─DS = [70:0x141af8000] <lgl> 
├─ESP = [71:0x3427c8000] <fct> 
├─ESR = [72:0x343508000] <fct> 
├─HISP = [73:0x1668c8000] <chr> 
├─INDP = [74:0x168348000] <chr> 
├─JWAP = [75:0x348000000] <chr> 
├─JWDP = [76:0x349a80000] <chr> 
├─LANP = [77:0x34b500000] <chr> 
├─MIGPUMA = [78:0x14e4e8000] <fct> 
├─MIGSP = [79:0x34cf80000] <chr> 
├─MSP = [80:0x14f228000] <fct> 
├─NAICSP = [81:0x34ea00000] <chr> 
├─NATIVITY = [82:0x358008000] <fct> 
├─OC = [83:0x142198000] <lgl> 
├─OCCP = [84:0x350480000] <chr> 
├─PAOC = [85:0x358d48000] <fct> 
├─PERNP = [86:0x359a88000] <int> 
├─PINCP = [87:0x35a7c8000] <int> 
├─POBP = [88:0x351f00000] <chr> 
├─POVPIP = [89:0x35b508000] <int> 
├─POWPUMA = [90:0x35c248000] <fct> 
├─POWSP = [91:0x353980000] <chr> 
├─QTRBIR = [92:0x35cf88000] <fct> 
├─RAC1P = [93:0x35dcc8000] <fct> 
├─RAC2P = [94:0x355400000] <chr> 
├─RAC3P = [95:0x356e80000] <chr> 
├─RACAIAN = [96:0x120788000] <lgl> 
├─RACASN = [97:0x120e28000] <lgl> 
├─RACBLK = [98:0x311a88000] <lgl> 
├─RACNHPI = [99:0x312128000] <lgl> 
├─RACNUM = [100:0x344248000] <int> 
├─RACSOR = [101:0x1517d0000] <lgl> 
├─RACWHT = [102:0x3127c8000] <lgl> 
├─RC = [103:0x312e68000] <lgl> 
├─SFN = [104:0x344f88000] <fct> 
├─SFR = [105:0x345cc8000] <fct> 
├─SOCP = [106:0x360d40000] <chr> 
├─VPS = [107:0x3627c0000] <chr> 
├─WAOB = [108:0x346a08000] <fct> 
├─FAGEP = [109:0x151e70000] <lgl> 
├─FANCP = [110:0x152510000] <lgl> 
├─FCITP = [111:0x152bb0000] <lgl> 
├─FCOWP = [112:0x153250000] <lgl> 
├─FDDRSP = [113:0x142838000] <lgl> 
├─FDEYEP = [114:0x142ed8000] <lgl> 
├─FDOUTP = [115:0x300de0000] <lgl> 
├─FDPHYP = [116:0x131ac8000] <lgl> 
├─FDREMP = [117:0x309b48000] <lgl> 
├─FDWRKP = [118:0x30a1e8000] <lgl> 
├─FENGP = [119:0x30a888000] <lgl> 
├─FESRP = [120:0x1214c8000] <lgl> 
├─FFERP = [121:0x121b68000] <lgl> 
├─FGCLP = [122:0x143578000] <lgl> 
├─FGCMP = [123:0x143c18000] <lgl> 
├─FGCRP = [124:0x1442b8000] <lgl> 
├─FHISP = [125:0x144958000] <lgl> 
├─FINDP = [126:0x144ff8000] <lgl> 
├─FINTP = [127:0x145698000] <lgl> 
├─FJWDP = [128:0x145d38000] <lgl> 
├─FJWMNP = [129:0x1463d8000] <lgl> 
├─FJWRIP = [130:0x1110d0000] <lgl> 
├─FJWTRP = [131:0x132168000] <lgl> 
├─FLANP = [132:0x318008000] <lgl> 
├─FLANXP = [133:0x1487b0000] <lgl> 
├─FMARP = [134:0x148e50000] <lgl> 
├─FMIGP = [135:0x1494f0000] <lgl> 
├─FMIGSP = [136:0x313508000] <lgl> 
├─FMILPP = [137:0x132808000] <lgl> 
├─FMILSP = [138:0x30af28000] <lgl> 
├─FMILYP = [139:0x301480000] <lgl> 
├─FOCCP = [140:0x111770000] <lgl> 
├─FOIP = [141:0x111e10000] <lgl> 
├─FPAP = [142:0x1124b0000] <lgl> 
├─FPOBP = [143:0x122208000] <lgl> 
├─FPOWSP = [144:0x313ba8000] <lgl> 
├─FRACP = [145:0x17b530000] <lgl> 
├─FRELP = [146:0x314248000] <lgl> 
├─FRETP = [147:0x1538f0000] <lgl> 
├─FSCHGP = [148:0x153f90000] <lgl> 
├─FSCHLP = [149:0x3148e8000] <lgl> 
├─FSCHP = [150:0x314f88000] <lgl> 
├─FSEMP = [151:0x170db0000] <lgl> 
├─FSEXP = [152:0x171450000] <lgl> 
├─FSSIP = [153:0x301b20000] <lgl> 
├─FSSP = [154:0x132ea8000] <lgl> 
├─FWAGP = [155:0x133548000] <lgl> 
├─FWKHP = [156:0x315628000] <lgl> 
├─FWKLP = [157:0x3021c0000] <lgl> 
├─FWKWP = [158:0x315cc8000] <lgl> 
├─FYOEP = [159:0x316368000] <lgl> 
├─PWGTP1 = [160:0x347748000] <int> 
├─PWGTP2 = [161:0x3686a8000] <int> 
├─PWGTP3 = [162:0x3693e8000] <int> 
├─PWGTP4 = [163:0x36a128000] <int> 
├─PWGTP5 = [164:0x36ae68000] <int> 
├─PWGTP6 = [165:0x36bba8000] <int> 
├─PWGTP7 = [166:0x36c8e8000] <int> 
├─PWGTP8 = [167:0x36d628000] <int> 
├─PWGTP9 = [168:0x36e368000] <int> 
├─PWGTP10 = [169:0x36f0a8000] <int> 
├─PWGTP11 = [170:0x370008000] <int> 
├─PWGTP12 = [171:0x370d48000] <int> 
├─PWGTP13 = [172:0x371a88000] <int> 
├─PWGTP14 = [173:0x3727c8000] <int> 
├─PWGTP15 = [174:0x373508000] <int> 
├─PWGTP16 = [175:0x374248000] <int> 
├─PWGTP17 = [176:0x374f88000] <int> 
├─PWGTP18 = [177:0x375cc8000] <int> 
├─PWGTP19 = [178:0x376a08000] <int> 
├─PWGTP20 = [179:0x377748000] <int> 
├─PWGTP21 = [180:0x3786a8000] <int> 
├─PWGTP22 = [181:0x3793e8000] <int> 
├─PWGTP23 = [182:0x37a128000] <int> 
├─PWGTP24 = [183:0x37ae68000] <int> 
├─PWGTP25 = [184:0x37bba8000] <int> 
├─PWGTP26 = [185:0x37c8e8000] <int> 
├─PWGTP27 = [186:0x37d628000] <int> 
├─PWGTP28 = [187:0x37e368000] <int> 
├─PWGTP29 = [188:0x37f0a8000] <int> 
├─PWGTP30 = [189:0x380008000] <int> 
├─PWGTP31 = [190:0x380d48000] <int> 
├─PWGTP32 = [191:0x381a88000] <int> 
├─PWGTP33 = [192:0x3827c8000] <int> 
├─PWGTP34 = [193:0x383508000] <int> 
├─PWGTP35 = [194:0x384248000] <int> 
├─PWGTP36 = [195:0x384f88000] <int> 
├─PWGTP37 = [196:0x385cc8000] <int> 
├─PWGTP38 = [197:0x386a08000] <int> 
├─PWGTP39 = [198:0x387748000] <int> 
├─PWGTP40 = [199:0x3886a8000] <int> 
├─PWGTP41 = [200:0x3893e8000] <int> 
├─PWGTP42 = [201:0x38a128000] <int> 
├─PWGTP43 = [202:0x38ae68000] <int> 
├─PWGTP44 = [203:0x38bba8000] <int> 
├─PWGTP45 = [204:0x38c8e8000] <int> 
├─PWGTP46 = [205:0x38d628000] <int> 
├─PWGTP47 = [206:0x38e368000] <int> 
├─PWGTP48 = [207:0x38f0a8000] <int> 
├─PWGTP49 = [208:0x390008000] <int> 
├─PWGTP50 = [209:0x390d48000] <int> 
├─PWGTP51 = [210:0x391a88000] <int> 
├─PWGTP52 = [211:0x3927c8000] <int> 
├─PWGTP53 = [212:0x393508000] <int> 
├─PWGTP54 = [213:0x394248000] <int> 
├─PWGTP55 = [214:0x394f88000] <int> 
├─PWGTP56 = [215:0x395cc8000] <int> 
├─PWGTP57 = [216:0x35ea08000] <int> 
├─PWGTP58 = [217:0x35f748000] <int> 
├─PWGTP59 = [218:0x3986a8000] <int> 
├─PWGTP60 = [219:0x3993e8000] <int> 
├─PWGTP61 = [220:0x39a128000] <int> 
├─PWGTP62 = [221:0x39ae68000] <int> 
├─PWGTP63 = [222:0x39bba8000] <int> 
├─PWGTP64 = [223:0x39c8e8000] <int> 
├─PWGTP65 = [224:0x39d628000] <int> 
├─PWGTP66 = [225:0x39e368000] <int> 
├─PWGTP67 = [226:0x39f0a8000] <int> 
├─PWGTP68 = [227:0x3a0008000] <int> 
├─PWGTP69 = [228:0x3a0d48000] <int> 
├─PWGTP70 = [229:0x3a1a88000] <int> 
├─PWGTP71 = [230:0x3a27c8000] <int> 
├─PWGTP72 = [231:0x3a3508000] <int> 
├─PWGTP73 = [232:0x3a4248000] <int> 
├─PWGTP74 = [233:0x3a4f88000] <int> 
├─PWGTP75 = [234:0x3a5cc8000] <int> 
├─PWGTP76 = [235:0x3a6a08000] <int> 
├─PWGTP77 = [236:0x3a7748000] <int> 
├─PWGTP78 = [237:0x3a86a8000] <int> 
├─PWGTP79 = [238:0x3a93e8000] <int> 
├─PWGTP80 = [239:0x3aa128000] <int> 
├─NOP = [240:0x3aae68000] <fct> 
├─ADJINC = [241:0x364240000] <dbl> 
├─CITWP = [242:0x365cc0000] <chr> 
├─DEAR = [243:0x30b5c8000] <lgl> 
├─DRAT = [244:0x3abba8000] <fct> 
├─DRATX = [245:0x133be8000] <lgl> 
├─HINS1 = [246:0x134288000] <lgl> 
├─HINS2 = [247:0x134928000] <lgl> 
├─HINS3 = [248:0x134fc8000] <lgl> 
├─HINS4 = [249:0x135668000] <lgl> 
├─HINS5 = [250:0x135d08000] <lgl> 
├─HINS6 = [251:0x1363a8000] <lgl> 
├─HINS7 = [252:0x136a48000] <lgl> 
├─MARHD = [253:0x1370e8000] <lgl> 
├─MARHM = [254:0x137788000] <lgl> 
├─MARHT = [255:0x3ac8e8000] <fct> 
├─MARHW = [256:0x320008000] <lgl> 
├─MARHYP = [257:0x3b0000000] <chr> 
├─DIS = [258:0x3206a8000] <lgl> 
├─HICOV = [259:0x320d48000] <lgl> 
├─PRIVCOV = [260:0x3213e8000] <lgl> 
├─PUBCOV = [261:0x321a88000] <lgl> 
├─FCITWP = [262:0x322128000] <lgl> 
├─FDEARP = [263:0x3227c8000] <lgl> 
├─FDRATP = [264:0x322e68000] <lgl> 
├─FDRATXP = [265:0x323508000] <lgl> 
├─FHINS1P = [266:0x323ba8000] <lgl> 
├─FHINS2P = [267:0x324248000] <lgl> 
├─FHINS3P = [268:0x149b90000] <lgl> 
├─FHINS4P = [269:0x30bc68000] <lgl> 
├─FHINS5P = [270:0x30c308000] <lgl> 
├─FHINS6P = [271:0x30c9a8000] <lgl> 
├─FHINS7P = [272:0x302860000] <lgl> 
├─FMARHDP = [273:0x30d048000] <lgl> 
├─FMARHMP = [274:0x316a08000] <lgl> 
├─FMARHTP = [275:0x3170a8000] <lgl> 
├─FMARHWP = [276:0x17bbd0000] <lgl> 
├─FMARHYP = [277:0x17c270000] <lgl> 
├─WRK = [278:0x17c910000] <lgl> 
├─FOD1P = [279:0x3b1a80000] <chr> 
├─FOD2P = [280:0x3b3500000] <chr> 
├─SCIENGP = [281:0x171af0000] <lgl> 
├─SCIENGRLP = [282:0x172190000] <lgl> 
├─FFODP = [283:0x112b50000] <lgl> 
├─FHINS3C = [284:0x122f48000] <fct> 
├─FHINS4C = [285:0x123c88000] <fct> 
├─FHINS5C = [286:0x1249c8000] <fct> 
├─RELP = [287:0x3b4f80000] <chr> 
├─FWRKP = [288:0x17cfb0000] <lgl> 
├─FDISP = [289:0x17d650000] <lgl> 
├─FPERNP = [290:0x17dcf0000] <lgl> 
├─FPINCP = [291:0x17e390000] <lgl> 
├─FPRIVCOVP = [292:0x317748000] <lgl> 
├─FPUBCOVP = [293:0x328008000] <lgl> 
├─RACNH = [294:0x146a78000] <lgl> 
├─RACPI = [295:0x302f00000] <lgl> 
├─SSPA = [296:0x125708000] <fct> 
├─MLPCD = [297:0x3186a8000] <lgl> 
├─MLPFG = [298:0x318d48000] <lgl> 
├─FHICOVP = [299:0x3193e8000] <lgl> 
├─DIVISION = [300:0x126448000] <fct> 
├─REGION = [301:0x127188000] <fct> 
├─HIMRKS = [302:0x3b8008000] <fct> 
├─JWTRNS = [303:0x3b6a00000] <chr> 
├─RELSHIPP = [304:0x3c0d40000] <chr> 
├─WKWN = [305:0x3b8d48000] <int> 
├─FHIMRKSP = [306:0x17ea30000] <lgl> 
├─FJWTRNSP = [307:0x3248e8000] <lgl> 
├─FRELSHIPP = [308:0x1228a8000] <lgl> 
├─FWKWNP = [309:0x319a88000] <lgl> 
├─MLPIK = [310:0x14a230000] <lgl> 
├─year = [311:0x3b9a88000] <int> 
├─location = [312:0x3c27c0000] <chr> 
├─age_groups = [313:0x34a7c0000] <chr> 
├─ins_type = [314:0x34c240000] <chr> 
└─age_decade = [315:0x366a00000] <dbl> 

3. Memory Efficient

Modify by reference - no copies

# Deep Copy (full dataset copied)
pums_copy <- copy(pums)

# adding variable to this does not alter the original
pums_copy[, age_decade := floor(AGEP / 10) * 10]
lobstr::ref(pums)
█ [1:0x10ceb7800] <dt[,314]> 
├─SPORDER = [2:0x324f88000] <int> 
├─RT = [3:0x325cc8000] <fct> 
├─SERIALNO = [4:0x11e900000] <chr> 
├─PUMA = [5:0x12b000000] <chr> 
├─ST = [6:0x138000000] <chr> 
├─ADJUST = [7:0x147118000] <int> 
├─PWGTP = [8:0x330008000] <int> 
├─AGEP = [9:0x330d48000] <int> 
├─CIT = [10:0x331a88000] <fct> 
├─COW = [11:0x3327c8000] <fct> 
├─DDRS = [12:0x150a90000] <lgl> 
├─DEYE = [13:0x178030000] <lgl> 
├─DOUT = [14:0x1786d0000] <lgl> 
├─DPHY = [15:0x178d70000] <lgl> 
├─DREM = [16:0x110390000] <lgl> 
├─DWRK = [17:0x310008000] <lgl> 
├─ENG = [18:0x333508000] <fct> 
├─FER = [19:0x110a30000] <lgl> 
├─GCL = [20:0x148110000] <lgl> 
├─GCM = [21:0x334248000] <fct> 
├─GCR = [22:0x3106a8000] <lgl> 
├─INTP = [23:0x334f88000] <int> 
├─JWMNP = [24:0x335cc8000] <int> 
├─JWRIP = [25:0x139a80000] <chr> 
├─JWTR = [26:0x13d800000] <chr> 
├─LANX = [27:0x310d48000] <lgl> 
├─MAR = [28:0x336a08000] <fct> 
├─MIG = [29:0x3113e8000] <lgl> 
├─MIL = [30:0x337748000] <fct> 
├─MILY = [31:0x3386a8000] <fct> 
├─MLPA = [32:0x3080c8000] <lgl> 
├─MLPB = [33:0x140db8000] <lgl> 
├─MLPC = [34:0x179410000] <lgl> 
├─MLPD = [35:0x308768000] <lgl> 
├─MLPE = [36:0x308e08000] <lgl> 
├─MLPF = [37:0x3094a8000] <lgl> 
├─MLPG = [38:0x3000a0000] <lgl> 
├─MLPH = [39:0x131428000] <lgl> 
├─MLPI = [40:0x179ab0000] <lgl> 
├─MLPJ = [41:0x17a150000] <lgl> 
├─MLPK = [42:0x17a7f0000] <lgl> 
├─NWAB = [43:0x17ae90000] <lgl> 
├─NWAV = [44:0x3393e8000] <fct> 
├─NWLA = [45:0x170070000] <lgl> 
├─NWLK = [46:0x170710000] <lgl> 
├─NWRE = [47:0x151130000] <lgl> 
├─OIP = [48:0x33a128000] <int> 
├─PAP = [49:0x33ae68000] <int> 
├─REL = [50:0x13f280000] <chr> 
├─RETP = [51:0x33bba8000] <int> 
├─SCH = [52:0x300740000] <lgl> 
├─SCHG = [53:0x158d40000] <chr> 
├─SCHL = [54:0x15a7c0000] <chr> 
├─SEMP = [55:0x14afe8000] <int> 
├─SEX = [56:0x14bd28000] <fct> 
├─SSIP = [57:0x14ca68000] <int> 
├─SSP = [58:0x14d7a8000] <int> 
├─WAGP = [59:0x154630000] <int> 
├─WKHP = [60:0x155370000] <int> 
├─WKL = [61:0x1560b0000] <fct> 
├─WKW = [62:0x156df0000] <fct> 
├─YOEP = [63:0x161948000] <chr> 
├─UWRK = [64:0x141458000] <lgl> 
├─ANC = [65:0x340008000] <fct> 
├─ANC1P = [66:0x1633c8000] <chr> 
├─ANC2P = [67:0x164e48000] <chr> 
├─DECADE = [68:0x340d48000] <fct> 
├─DRIVESP = [69:0x341a88000] <fct> 
├─DS = [70:0x141af8000] <lgl> 
├─ESP = [71:0x3427c8000] <fct> 
├─ESR = [72:0x343508000] <fct> 
├─HISP = [73:0x1668c8000] <chr> 
├─INDP = [74:0x168348000] <chr> 
├─JWAP = [75:0x348000000] <chr> 
├─JWDP = [76:0x349a80000] <chr> 
├─LANP = [77:0x34b500000] <chr> 
├─MIGPUMA = [78:0x14e4e8000] <fct> 
├─MIGSP = [79:0x34cf80000] <chr> 
├─MSP = [80:0x14f228000] <fct> 
├─NAICSP = [81:0x34ea00000] <chr> 
├─NATIVITY = [82:0x358008000] <fct> 
├─OC = [83:0x142198000] <lgl> 
├─OCCP = [84:0x350480000] <chr> 
├─PAOC = [85:0x358d48000] <fct> 
├─PERNP = [86:0x359a88000] <int> 
├─PINCP = [87:0x35a7c8000] <int> 
├─POBP = [88:0x351f00000] <chr> 
├─POVPIP = [89:0x35b508000] <int> 
├─POWPUMA = [90:0x35c248000] <fct> 
├─POWSP = [91:0x353980000] <chr> 
├─QTRBIR = [92:0x35cf88000] <fct> 
├─RAC1P = [93:0x35dcc8000] <fct> 
├─RAC2P = [94:0x355400000] <chr> 
├─RAC3P = [95:0x356e80000] <chr> 
├─RACAIAN = [96:0x120788000] <lgl> 
├─RACASN = [97:0x120e28000] <lgl> 
├─RACBLK = [98:0x311a88000] <lgl> 
├─RACNHPI = [99:0x312128000] <lgl> 
├─RACNUM = [100:0x344248000] <int> 
├─RACSOR = [101:0x1517d0000] <lgl> 
├─RACWHT = [102:0x3127c8000] <lgl> 
├─RC = [103:0x312e68000] <lgl> 
├─SFN = [104:0x344f88000] <fct> 
├─SFR = [105:0x345cc8000] <fct> 
├─SOCP = [106:0x360d40000] <chr> 
├─VPS = [107:0x3627c0000] <chr> 
├─WAOB = [108:0x346a08000] <fct> 
├─FAGEP = [109:0x151e70000] <lgl> 
├─FANCP = [110:0x152510000] <lgl> 
├─FCITP = [111:0x152bb0000] <lgl> 
├─FCOWP = [112:0x153250000] <lgl> 
├─FDDRSP = [113:0x142838000] <lgl> 
├─FDEYEP = [114:0x142ed8000] <lgl> 
├─FDOUTP = [115:0x300de0000] <lgl> 
├─FDPHYP = [116:0x131ac8000] <lgl> 
├─FDREMP = [117:0x309b48000] <lgl> 
├─FDWRKP = [118:0x30a1e8000] <lgl> 
├─FENGP = [119:0x30a888000] <lgl> 
├─FESRP = [120:0x1214c8000] <lgl> 
├─FFERP = [121:0x121b68000] <lgl> 
├─FGCLP = [122:0x143578000] <lgl> 
├─FGCMP = [123:0x143c18000] <lgl> 
├─FGCRP = [124:0x1442b8000] <lgl> 
├─FHISP = [125:0x144958000] <lgl> 
├─FINDP = [126:0x144ff8000] <lgl> 
├─FINTP = [127:0x145698000] <lgl> 
├─FJWDP = [128:0x145d38000] <lgl> 
├─FJWMNP = [129:0x1463d8000] <lgl> 
├─FJWRIP = [130:0x1110d0000] <lgl> 
├─FJWTRP = [131:0x132168000] <lgl> 
├─FLANP = [132:0x318008000] <lgl> 
├─FLANXP = [133:0x1487b0000] <lgl> 
├─FMARP = [134:0x148e50000] <lgl> 
├─FMIGP = [135:0x1494f0000] <lgl> 
├─FMIGSP = [136:0x313508000] <lgl> 
├─FMILPP = [137:0x132808000] <lgl> 
├─FMILSP = [138:0x30af28000] <lgl> 
├─FMILYP = [139:0x301480000] <lgl> 
├─FOCCP = [140:0x111770000] <lgl> 
├─FOIP = [141:0x111e10000] <lgl> 
├─FPAP = [142:0x1124b0000] <lgl> 
├─FPOBP = [143:0x122208000] <lgl> 
├─FPOWSP = [144:0x313ba8000] <lgl> 
├─FRACP = [145:0x17b530000] <lgl> 
├─FRELP = [146:0x314248000] <lgl> 
├─FRETP = [147:0x1538f0000] <lgl> 
├─FSCHGP = [148:0x153f90000] <lgl> 
├─FSCHLP = [149:0x3148e8000] <lgl> 
├─FSCHP = [150:0x314f88000] <lgl> 
├─FSEMP = [151:0x170db0000] <lgl> 
├─FSEXP = [152:0x171450000] <lgl> 
├─FSSIP = [153:0x301b20000] <lgl> 
├─FSSP = [154:0x132ea8000] <lgl> 
├─FWAGP = [155:0x133548000] <lgl> 
├─FWKHP = [156:0x315628000] <lgl> 
├─FWKLP = [157:0x3021c0000] <lgl> 
├─FWKWP = [158:0x315cc8000] <lgl> 
├─FYOEP = [159:0x316368000] <lgl> 
├─PWGTP1 = [160:0x347748000] <int> 
├─PWGTP2 = [161:0x3686a8000] <int> 
├─PWGTP3 = [162:0x3693e8000] <int> 
├─PWGTP4 = [163:0x36a128000] <int> 
├─PWGTP5 = [164:0x36ae68000] <int> 
├─PWGTP6 = [165:0x36bba8000] <int> 
├─PWGTP7 = [166:0x36c8e8000] <int> 
├─PWGTP8 = [167:0x36d628000] <int> 
├─PWGTP9 = [168:0x36e368000] <int> 
├─PWGTP10 = [169:0x36f0a8000] <int> 
├─PWGTP11 = [170:0x370008000] <int> 
├─PWGTP12 = [171:0x370d48000] <int> 
├─PWGTP13 = [172:0x371a88000] <int> 
├─PWGTP14 = [173:0x3727c8000] <int> 
├─PWGTP15 = [174:0x373508000] <int> 
├─PWGTP16 = [175:0x374248000] <int> 
├─PWGTP17 = [176:0x374f88000] <int> 
├─PWGTP18 = [177:0x375cc8000] <int> 
├─PWGTP19 = [178:0x376a08000] <int> 
├─PWGTP20 = [179:0x377748000] <int> 
├─PWGTP21 = [180:0x3786a8000] <int> 
├─PWGTP22 = [181:0x3793e8000] <int> 
├─PWGTP23 = [182:0x37a128000] <int> 
├─PWGTP24 = [183:0x37ae68000] <int> 
├─PWGTP25 = [184:0x37bba8000] <int> 
├─PWGTP26 = [185:0x37c8e8000] <int> 
├─PWGTP27 = [186:0x37d628000] <int> 
├─PWGTP28 = [187:0x37e368000] <int> 
├─PWGTP29 = [188:0x37f0a8000] <int> 
├─PWGTP30 = [189:0x380008000] <int> 
├─PWGTP31 = [190:0x380d48000] <int> 
├─PWGTP32 = [191:0x381a88000] <int> 
├─PWGTP33 = [192:0x3827c8000] <int> 
├─PWGTP34 = [193:0x383508000] <int> 
├─PWGTP35 = [194:0x384248000] <int> 
├─PWGTP36 = [195:0x384f88000] <int> 
├─PWGTP37 = [196:0x385cc8000] <int> 
├─PWGTP38 = [197:0x386a08000] <int> 
├─PWGTP39 = [198:0x387748000] <int> 
├─PWGTP40 = [199:0x3886a8000] <int> 
├─PWGTP41 = [200:0x3893e8000] <int> 
├─PWGTP42 = [201:0x38a128000] <int> 
├─PWGTP43 = [202:0x38ae68000] <int> 
├─PWGTP44 = [203:0x38bba8000] <int> 
├─PWGTP45 = [204:0x38c8e8000] <int> 
├─PWGTP46 = [205:0x38d628000] <int> 
├─PWGTP47 = [206:0x38e368000] <int> 
├─PWGTP48 = [207:0x38f0a8000] <int> 
├─PWGTP49 = [208:0x390008000] <int> 
├─PWGTP50 = [209:0x390d48000] <int> 
├─PWGTP51 = [210:0x391a88000] <int> 
├─PWGTP52 = [211:0x3927c8000] <int> 
├─PWGTP53 = [212:0x393508000] <int> 
├─PWGTP54 = [213:0x394248000] <int> 
├─PWGTP55 = [214:0x394f88000] <int> 
├─PWGTP56 = [215:0x395cc8000] <int> 
├─PWGTP57 = [216:0x35ea08000] <int> 
├─PWGTP58 = [217:0x35f748000] <int> 
├─PWGTP59 = [218:0x3986a8000] <int> 
├─PWGTP60 = [219:0x3993e8000] <int> 
├─PWGTP61 = [220:0x39a128000] <int> 
├─PWGTP62 = [221:0x39ae68000] <int> 
├─PWGTP63 = [222:0x39bba8000] <int> 
├─PWGTP64 = [223:0x39c8e8000] <int> 
├─PWGTP65 = [224:0x39d628000] <int> 
├─PWGTP66 = [225:0x39e368000] <int> 
├─PWGTP67 = [226:0x39f0a8000] <int> 
├─PWGTP68 = [227:0x3a0008000] <int> 
├─PWGTP69 = [228:0x3a0d48000] <int> 
├─PWGTP70 = [229:0x3a1a88000] <int> 
├─PWGTP71 = [230:0x3a27c8000] <int> 
├─PWGTP72 = [231:0x3a3508000] <int> 
├─PWGTP73 = [232:0x3a4248000] <int> 
├─PWGTP74 = [233:0x3a4f88000] <int> 
├─PWGTP75 = [234:0x3a5cc8000] <int> 
├─PWGTP76 = [235:0x3a6a08000] <int> 
├─PWGTP77 = [236:0x3a7748000] <int> 
├─PWGTP78 = [237:0x3a86a8000] <int> 
├─PWGTP79 = [238:0x3a93e8000] <int> 
├─PWGTP80 = [239:0x3aa128000] <int> 
├─NOP = [240:0x3aae68000] <fct> 
├─ADJINC = [241:0x364240000] <dbl> 
├─CITWP = [242:0x365cc0000] <chr> 
├─DEAR = [243:0x30b5c8000] <lgl> 
├─DRAT = [244:0x3abba8000] <fct> 
├─DRATX = [245:0x133be8000] <lgl> 
├─HINS1 = [246:0x134288000] <lgl> 
├─HINS2 = [247:0x134928000] <lgl> 
├─HINS3 = [248:0x134fc8000] <lgl> 
├─HINS4 = [249:0x135668000] <lgl> 
├─HINS5 = [250:0x135d08000] <lgl> 
├─HINS6 = [251:0x1363a8000] <lgl> 
├─HINS7 = [252:0x136a48000] <lgl> 
├─MARHD = [253:0x1370e8000] <lgl> 
├─MARHM = [254:0x137788000] <lgl> 
├─MARHT = [255:0x3ac8e8000] <fct> 
├─MARHW = [256:0x320008000] <lgl> 
├─MARHYP = [257:0x3b0000000] <chr> 
├─DIS = [258:0x3206a8000] <lgl> 
├─HICOV = [259:0x320d48000] <lgl> 
├─PRIVCOV = [260:0x3213e8000] <lgl> 
├─PUBCOV = [261:0x321a88000] <lgl> 
├─FCITWP = [262:0x322128000] <lgl> 
├─FDEARP = [263:0x3227c8000] <lgl> 
├─FDRATP = [264:0x322e68000] <lgl> 
├─FDRATXP = [265:0x323508000] <lgl> 
├─FHINS1P = [266:0x323ba8000] <lgl> 
├─FHINS2P = [267:0x324248000] <lgl> 
├─FHINS3P = [268:0x149b90000] <lgl> 
├─FHINS4P = [269:0x30bc68000] <lgl> 
├─FHINS5P = [270:0x30c308000] <lgl> 
├─FHINS6P = [271:0x30c9a8000] <lgl> 
├─FHINS7P = [272:0x302860000] <lgl> 
├─FMARHDP = [273:0x30d048000] <lgl> 
├─FMARHMP = [274:0x316a08000] <lgl> 
├─FMARHTP = [275:0x3170a8000] <lgl> 
├─FMARHWP = [276:0x17bbd0000] <lgl> 
├─FMARHYP = [277:0x17c270000] <lgl> 
├─WRK = [278:0x17c910000] <lgl> 
├─FOD1P = [279:0x3b1a80000] <chr> 
├─FOD2P = [280:0x3b3500000] <chr> 
├─SCIENGP = [281:0x171af0000] <lgl> 
├─SCIENGRLP = [282:0x172190000] <lgl> 
├─FFODP = [283:0x112b50000] <lgl> 
├─FHINS3C = [284:0x122f48000] <fct> 
├─FHINS4C = [285:0x123c88000] <fct> 
├─FHINS5C = [286:0x1249c8000] <fct> 
├─RELP = [287:0x3b4f80000] <chr> 
├─FWRKP = [288:0x17cfb0000] <lgl> 
├─FDISP = [289:0x17d650000] <lgl> 
├─FPERNP = [290:0x17dcf0000] <lgl> 
├─FPINCP = [291:0x17e390000] <lgl> 
├─FPRIVCOVP = [292:0x317748000] <lgl> 
├─FPUBCOVP = [293:0x328008000] <lgl> 
├─RACNH = [294:0x146a78000] <lgl> 
├─RACPI = [295:0x302f00000] <lgl> 
├─SSPA = [296:0x125708000] <fct> 
├─MLPCD = [297:0x3186a8000] <lgl> 
├─MLPFG = [298:0x318d48000] <lgl> 
├─FHICOVP = [299:0x3193e8000] <lgl> 
├─DIVISION = [300:0x126448000] <fct> 
├─REGION = [301:0x127188000] <fct> 
├─HIMRKS = [302:0x3b8008000] <fct> 
├─JWTRNS = [303:0x3b6a00000] <chr> 
├─RELSHIPP = [304:0x3c0d40000] <chr> 
├─WKWN = [305:0x3b8d48000] <int> 
├─FHIMRKSP = [306:0x17ea30000] <lgl> 
├─FJWTRNSP = [307:0x3248e8000] <lgl> 
├─FRELSHIPP = [308:0x1228a8000] <lgl> 
├─FWKWNP = [309:0x319a88000] <lgl> 
├─MLPIK = [310:0x14a230000] <lgl> 
├─year = [311:0x3b9a88000] <int> 
├─location = [312:0x3c27c0000] <chr> 
├─age_groups = [313:0x34a7c0000] <chr> 
├─ins_type = [314:0x34c240000] <chr> 
└─age_decade = [315:0x366a00000] <dbl> 
lobstr::ref(pums_copy)
█ [1:0x11d385800] <dt[,314]> 
├─SPORDER = [2:0x477808000] <int> 
├─RT = [3:0x470308000] <fct> 
├─SERIALNO = [4:0x3b27c0000] <chr> 
├─PUMA = [5:0x3b0d40000] <chr> 
├─ST = [6:0x34dcc0000] <chr> 
├─ADJUST = [7:0x416148000] <int> 
├─PWGTP = [8:0x470b28000] <int> 
├─AGEP = [9:0x415628000] <int> 
├─CIT = [10:0x4173a8000] <fct> 
├─COW = [11:0x475828000] <fct> 
├─DDRS = [12:0x4744e8000] <lgl> 
├─DEYE = [13:0x451648000] <lgl> 
├─DOUT = [14:0x3a2e68000] <lgl> 
├─DPHY = [15:0x3a48e8000] <lgl> 
├─DREM = [16:0x3a70a8000] <lgl> 
├─DWRK = [17:0x457808000] <lgl> 
├─ENG = [18:0x4531a8000] <fct> 
├─FER = [19:0x14f8c8000] <lgl> 
├─GCL = [20:0x438308000] <lgl> 
├─GCM = [21:0x43be48000] <fct> 
├─GCR = [22:0x42b028000] <lgl> 
├─INTP = [23:0x41e2c8000] <int> 
├─JWMNP = [24:0x41d928000] <int> 
├─JWRIP = [25:0x34f740000] <chr> 
├─JWTR = [26:0x3511c0000] <chr> 
├─LANX = [27:0x4193e8000] <lgl> 
├─MAR = [28:0x43b4a8000] <fct> 
├─MIG = [29:0x41f488000] <lgl> 
├─MIL = [30:0x4397c8000] <fct> 
├─MILY = [31:0x431fe8000] <fct> 
├─MLPA = [32:0x430188000] <lgl> 
├─MLPB = [33:0x3fcf88000] <lgl> 
├─MLPC = [34:0x4331a8000] <lgl> 
├─MLPD = [35:0x4314c8000] <lgl> 
├─MLPE = [36:0x433b48000] <lgl> 
├─MLPF = [37:0x434668000] <lgl> 
├─MLPG = [38:0x3fd928000] <lgl> 
├─MLPH = [39:0x3fdfc8000] <lgl> 
├─MLPI = [40:0x430b28000] <lgl> 
├─MLPJ = [41:0x4356a8000] <lgl> 
├─MLPK = [42:0x435d48000] <lgl> 
├─NWAB = [43:0x4363e8000] <lgl> 
├─NWAV = [44:0x436a88000] <fct> 
├─NWLA = [45:0x4761c8000] <lgl> 
├─NWLK = [46:0x471e68000] <lgl> 
├─NWRE = [47:0x4714c8000] <lgl> 
├─OIP = [48:0x473b48000] <int> 
├─PAP = [49:0x3948e8000] <int> 
├─REL = [50:0x352c40000] <chr> 
├─RETP = [51:0x3973a8000] <int> 
├─SCH = [52:0x393ba8000] <lgl> 
├─SCHG = [53:0x3546c0000] <chr> 
├─SCHL = [54:0x356140000] <chr> 
├─SEMP = [55:0x392128000] <int> 
├─SEX = [56:0x3913e8000] <fct> 
├─SSIP = [57:0x396668000] <int> 
├─SSP = [58:0x456e68000] <int> 
├─WAGP = [59:0x456348000] <int> 
├─WKHP = [60:0x455828000] <int> 
├─WKL = [61:0x472808000] <fct> 
├─WKW = [62:0x437128000] <fct> 
├─YOEP = [63:0x360000000] <chr> 
├─UWRK = [64:0x42dec8000] <lgl> 
├─ANC = [65:0x42e568000] <fct> 
├─ANC1P = [66:0x361a80000] <chr> 
├─ANC2P = [67:0x363500000] <chr> 
├─DECADE = [68:0x476ce8000] <fct> 
├─DRIVESP = [69:0x474e88000] <fct> 
├─DS = [70:0x4731a8000] <lgl> 
├─ESP = [71:0x38f748000] <fct> 
├─ESR = [72:0x38ea08000] <fct> 
├─HISP = [73:0x364f80000] <chr> 
├─INDP = [74:0x3b4240000] <chr> 
├─JWAP = [75:0x3b5cc0000] <chr> 
├─JWDP = [76:0x478000000] <chr> 
├─LANP = [77:0x479a7c000] <chr> 
├─MIGPUMA = [78:0x41b2e8000] <fct> 
├─MIGSP = [79:0x47b4f8000] <chr> 
├─MSP = [80:0x428828000] <fct> 
├─NAICSP = [81:0x47cf74000] <chr> 
├─NATIVITY = [82:0x4377c8000] <fct> 
├─OC = [83:0x45be48000] <lgl> 
├─OCCP = [84:0x47e9f0000] <chr> 
├─PAOC = [85:0x45f808000] <fct> 
├─PERNP = [86:0x45e348000] <int> 
├─PINCP = [87:0x45d9a8000] <int> 
├─POBP = [88:0x48046c000] <chr> 
├─POVPIP = [89:0x45d008000] <int> 
├─POWPUMA = [90:0x45c668000] <fct> 
├─POWSP = [91:0x481ee8000] <chr> 
├─QTRBIR = [92:0x45a988000] <fct> 
├─RAC1P = [93:0x42a508000] <fct> 
├─RAC2P = [94:0x483964000] <chr> 
├─RAC3P = [95:0x4853e0000] <chr> 
├─RACAIAN = [96:0x43d9a8000] <lgl> 
├─RACASN = [97:0x43e048000] <lgl> 
├─RACBLK = [98:0x43e6e8000] <lgl> 
├─RACNHPI = [99:0x38dcc8000] <lgl> 
├─RACNUM = [100:0x4291c8000] <int> 
├─RACSOR = [101:0x38c248000] <lgl> 
├─RACWHT = [102:0x389a88000] <lgl> 
├─RC = [103:0x388d48000] <lgl> 
├─SFN = [104:0x4267c8000] <fct> 
├─SFR = [105:0x422688000] <fct> 
├─SOCP = [106:0x486e5c000] <chr> 
├─VPS = [107:0x4888d8000] <chr> 
├─WAOB = [108:0x459fe8000] <fct> 
├─FAGEP = [109:0x421ce8000] <lgl> 
├─FANCP = [110:0x459648000] <lgl> 
├─FCITP = [111:0x458308000] <lgl> 
├─FCOWP = [112:0x427168000] <lgl> 
├─FDDRSP = [113:0x424b88000] <lgl> 
├─FDEYEP = [114:0x3acf88000] <lgl> 
├─FDOUTP = [115:0x454e88000] <lgl> 
├─FDPHYP = [116:0x43c668000] <lgl> 
├─FDREMP = [117:0x3aa7c8000] <lgl> 
├─FDWRKP = [118:0x3a9a88000] <lgl> 
├─FENGP = [119:0x4241e8000] <lgl> 
├─FESRP = [120:0x3af228000] <lgl> 
├─FFERP = [121:0x44f8a8000] <lgl> 
├─FGCLP = [122:0x423848000] <lgl> 
├─FGCMP = [123:0x41be08000] <lgl> 
├─FGCRP = [124:0x41c928000] <lgl> 
├─FHISP = [125:0x438ca8000] <lgl> 
├─FINDP = [126:0x420828000] <lgl> 
├─FINTP = [127:0x43a168000] <lgl> 
├─FJWDP = [128:0x43ab08000] <lgl> 
├─FJWMNP = [129:0x4544e8000] <lgl> 
├─FJWRIP = [130:0x42d528000] <lgl> 
├─FJWTRP = [131:0x46f508000] <lgl> 
├─FLANP = [132:0x42c1e8000] <lgl> 
├─FLANXP = [133:0x46e9e8000] <lgl> 
├─FMARP = [134:0x46e048000] <lgl> 
├─FMIGP = [135:0x46d6a8000] <lgl> 
├─FMIGSP = [136:0x46cd08000] <lgl> 
├─FMILPP = [137:0x46c368000] <lgl> 
├─FMILSP = [138:0x46b9c8000] <lgl> 
├─FMILYP = [139:0x44ef08000] <lgl> 
├─FOCCP = [140:0x46b028000] <lgl> 
├─FOIP = [141:0x44e568000] <lgl> 
├─FPAP = [142:0x44dbc8000] <lgl> 
├─FPOBP = [143:0x41a088000] <lgl> 
├─FPOWSP = [144:0x41a728000] <lgl> 
├─FRACP = [145:0x46a688000] <lgl> 
├─FRELP = [146:0x43d008000] <lgl> 
├─FRETP = [147:0x155a10000] <lgl> 
├─FSCHGP = [148:0x43f088000] <lgl> 
├─FSCHLP = [149:0x116050000] <lgl> 
├─FSCHP = [150:0x1166f0000] <lgl> 
├─FSEMP = [151:0x116d90000] <lgl> 
├─FSEXP = [152:0x117430000] <lgl> 
├─FSSIP = [153:0x467508000] <lgl> 
├─FSSP = [154:0x466b68000] <lgl> 
├─FWAGP = [155:0x469ce8000] <lgl> 
├─FWKHP = [156:0x469348000] <lgl> 
├─FWKLP = [157:0x4689a8000] <lgl> 
├─FWKWP = [158:0x468008000] <lgl> 
├─FYOEP = [159:0x44d228000] <lgl> 
├─PWGTP1 = [160:0x490008000] <int> 
├─PWGTP2 = [161:0x4906a8000] <int> 
├─PWGTP3 = [162:0x490d48000] <int> 
├─PWGTP4 = [163:0x43f728000] <int> 
├─PWGTP5 = [164:0x498008000] <int> 
├─PWGTP6 = [165:0x4986a8000] <int> 
├─PWGTP7 = [166:0x498d48000] <int> 
├─PWGTP8 = [167:0x4993e8000] <int> 
├─PWGTP9 = [168:0x4913e8000] <int> 
├─PWGTP10 = [169:0x499a88000] <int> 
├─PWGTP11 = [170:0x491a88000] <int> 
├─PWGTP12 = [171:0x49a128000] <int> 
├─PWGTP13 = [172:0x492128000] <int> 
├─PWGTP14 = [173:0x49a7c8000] <int> 
├─PWGTP15 = [174:0x49ae68000] <int> 
├─PWGTP16 = [175:0x49b508000] <int> 
├─PWGTP17 = [176:0x49bba8000] <int> 
├─PWGTP18 = [177:0x49c248000] <int> 
├─PWGTP19 = [178:0x49c8e8000] <int> 
├─PWGTP20 = [179:0x156750000] <int> 
├─PWGTP21 = [180:0x4436c8000] <int> 
├─PWGTP22 = [181:0x157490000] <int> 
├─PWGTP23 = [182:0x4927c8000] <int> 
├─PWGTP24 = [183:0x492e68000] <int> 
├─PWGTP25 = [184:0x493508000] <int> 
├─PWGTP26 = [185:0x493ba8000] <int> 
├─PWGTP27 = [186:0x494248000] <int> 
├─PWGTP28 = [187:0x4948e8000] <int> 
├─PWGTP29 = [188:0x494f88000] <int> 
├─PWGTP30 = [189:0x495628000] <int> 
├─PWGTP31 = [190:0x495cc8000] <int> 
├─PWGTP32 = [191:0x496368000] <int> 
├─PWGTP33 = [192:0x44c888000] <int> 
├─PWGTP34 = [193:0x496a08000] <int> 
├─PWGTP35 = [194:0x4970a8000] <int> 
├─PWGTP36 = [195:0x49cf88000] <int> 
├─PWGTP37 = [196:0x49d628000] <int> 
├─PWGTP38 = [197:0x4661c8000] <int> 
├─PWGTP39 = [198:0x465828000] <int> 
├─PWGTP40 = [199:0x464e88000] <int> 
├─PWGTP41 = [200:0x4644e8000] <int> 
├─PWGTP42 = [201:0x49dcc8000] <int> 
├─PWGTP43 = [202:0x49e368000] <int> 
├─PWGTP44 = [203:0x49ea08000] <int> 
├─PWGTP45 = [204:0x453b48000] <int> 
├─PWGTP46 = [205:0x450188000] <int> 
├─PWGTP47 = [206:0x44bee8000] <int> 
├─PWGTP48 = [207:0x49f0a8000] <int> 
├─PWGTP49 = [208:0x49f748000] <int> 
├─PWGTP50 = [209:0x4a0008000] <int> 
├─PWGTP51 = [210:0x497748000] <int> 
├─PWGTP52 = [211:0x44b548000] <int> 
├─PWGTP53 = [212:0x44aba8000] <int> 
├─PWGTP54 = [213:0x44a208000] <int> 
├─PWGTP55 = [214:0x4a06a8000] <int> 
├─PWGTP56 = [215:0x4a0d48000] <int> 
├─PWGTP57 = [216:0x4a13e8000] <int> 
├─PWGTP58 = [217:0x4a1a88000] <int> 
├─PWGTP59 = [218:0x4a2128000] <int> 
├─PWGTP60 = [219:0x4a27c8000] <int> 
├─PWGTP61 = [220:0x4a2e68000] <int> 
├─PWGTP62 = [221:0x4a3508000] <int> 
├─PWGTP63 = [222:0x4a8008000] <int> 
├─PWGTP64 = [223:0x4a86a8000] <int> 
├─PWGTP65 = [224:0x4a8d48000] <int> 
├─PWGTP66 = [225:0x4a93e8000] <int> 
├─PWGTP67 = [226:0x4a9a88000] <int> 
├─PWGTP68 = [227:0x449868000] <int> 
├─PWGTP69 = [228:0x4a3ba8000] <int> 
├─PWGTP70 = [229:0x463b48000] <int> 
├─PWGTP71 = [230:0x4631a8000] <int> 
├─PWGTP72 = [231:0x462808000] <int> 
├─PWGTP73 = [232:0x451e68000] <int> 
├─PWGTP74 = [233:0x452808000] <int> 
├─PWGTP75 = [234:0x4b0008000] <int> 
├─PWGTP76 = [235:0x4a4248000] <int> 
├─PWGTP77 = [236:0x448ec8000] <int> 
├─PWGTP78 = [237:0x461e68000] <int> 
├─PWGTP79 = [238:0x4614c8000] <int> 
├─PWGTP80 = [239:0x4a48e8000] <int> 
├─NOP = [240:0x4a4f88000] <fct> 
├─ADJINC = [241:0x489618000] <dbl> 
├─CITWP = [242:0x48a358000] <chr> 
├─DEAR = [243:0x448188000] <lgl> 
├─DRAT = [244:0x4a5628000] <fct> 
├─DRATX = [245:0x4a5cc8000] <lgl> 
├─HINS1 = [246:0x4b8008000] <lgl> 
├─HINS2 = [247:0x4b86a8000] <lgl> 
├─HINS3 = [248:0x4b8d48000] <lgl> 
├─HINS4 = [249:0x4b93e8000] <lgl> 
├─HINS5 = [250:0x4b9a88000] <lgl> 
├─HINS6 = [251:0x4ba128000] <lgl> 
├─HINS7 = [252:0x4ba7c8000] <lgl> 
├─MARHD = [253:0x4bae68000] <lgl> 
├─MARHM = [254:0x4bb508000] <lgl> 
├─MARHT = [255:0x4a6368000] <fct> 
├─MARHW = [256:0x4a6a08000] <lgl> 
├─MARHYP = [257:0x48b098000] <chr> 
├─DIS = [258:0x4a70a8000] <lgl> 
├─HICOV = [259:0x4a7748000] <lgl> 
├─PRIVCOV = [260:0x4bbba8000] <lgl> 
├─PUBCOV = [261:0x4c0008000] <lgl> 
├─FCITWP = [262:0x4aa128000] <lgl> 
├─FDEARP = [263:0x4c06a8000] <lgl> 
├─FDRATP = [264:0x4c0d48000] <lgl> 
├─FDRATXP = [265:0x4c13e8000] <lgl> 
├─FHINS1P = [266:0x4c1a88000] <lgl> 
├─FHINS2P = [267:0x4aa7c8000] <lgl> 
├─FHINS3P = [268:0x4aae68000] <lgl> 
├─FHINS4P = [269:0x4ab508000] <lgl> 
├─FHINS5P = [270:0x4c2128000] <lgl> 
├─FHINS6P = [271:0x4bc248000] <lgl> 
├─FHINS7P = [272:0x4c27c8000] <lgl> 
├─FMARHDP = [273:0x4c2e68000] <lgl> 
├─FMARHMP = [274:0x4b06a8000] <lgl> 
├─FMARHTP = [275:0x4abba8000] <lgl> 
├─FMARHWP = [276:0x4ac248000] <lgl> 
├─FMARHYP = [277:0x4c3508000] <lgl> 
├─WRK = [278:0x4c3ba8000] <lgl> 
├─FOD1P = [279:0x48bdd8000] <chr> 
├─FOD2P = [280:0x48cb18000] <chr> 
├─SCIENGP = [281:0x4c4248000] <lgl> 
├─SCIENGRLP = [282:0x4c48e8000] <lgl> 
├─FFODP = [283:0x4bc8e8000] <lgl> 
├─FHINS3C = [284:0x4ac8e8000] <fct> 
├─FHINS4C = [285:0x4acf88000] <fct> 
├─FHINS5C = [286:0x4bcf88000] <fct> 
├─RELP = [287:0x48d858000] <chr> 
├─FWRKP = [288:0x444a08000] <lgl> 
├─FDISP = [289:0x4450a8000] <lgl> 
├─FPERNP = [290:0x4ad628000] <lgl> 
├─FPINCP = [291:0x4adcc8000] <lgl> 
├─FPRIVCOVP = [292:0x4c4f88000] <lgl> 
├─FPUBCOVP = [293:0x4bd628000] <lgl> 
├─RACNH = [294:0x4c5628000] <lgl> 
├─RACPI = [295:0x4c5cc8000] <lgl> 
├─SSPA = [296:0x4c6368000] <fct> 
├─MLPCD = [297:0x4bdcc8000] <lgl> 
├─MLPFG = [298:0x4c6a08000] <lgl> 
├─FHICOVP = [299:0x4ae368000] <lgl> 
├─DIVISION = [300:0x4c70a8000] <fct> 
├─REGION = [301:0x4aea08000] <fct> 
├─HIMRKS = [302:0x4b0d48000] <fct> 
├─JWTRNS = [303:0x48e598000] <chr> 
├─RELSHIPP = [304:0x4c8000000] <chr> 
├─WKWN = [305:0x4c7748000] <int> 
├─FHIMRKSP = [306:0x4d0008000] <lgl> 
├─FJWTRNSP = [307:0x4d06a8000] <lgl> 
├─FRELSHIPP = [308:0x4af0a8000] <lgl> 
├─FWKWNP = [309:0x4af748000] <lgl> 
├─MLPIK = [310:0x4d0d48000] <lgl> 
├─year = [311:0x4b13e8000] <int> 
├─location = [312:0x4c8d40000] <chr> 
├─age_groups = [313:0x4c9a80000] <chr> 
├─ins_type = [314:0x4ca7c0000] <chr> 
└─age_decade = [315:0x4cc240000] <dbl> 

set*() Functions

Memory-efficient operations by reference

The set*() family of functions modify data.table objects directly in memory without creating copies, making them essential for large datasets.

Why set functions are useful:

  1. Memory efficiency: No copies made, lower RAM usage
  2. Speed: Faster than traditional assignment operations
  3. Large data friendly: Essential when working with datasets that approach memory limits
  4. Consistent syntax: Uniform approach across different operations

Key set functions:

# setnames() - rename columns by reference
setnames(pums, "AGEP", "age") 
setnames(pums, c("old1", "old2"), c("new1", "new2"))

# setkey() - set keys for fast operations
setkey(pums, ST, year)  # Fast lookups and joins

# setorder() - sort by reference
setorder(pums, ST, -AGEP)  # Sort by state, then age descending

# set() - general purpose setter
set(pums, i = 1L, j = "AGEP", value = 99L)  # Set specific cell
set(pums, j = "new_col", value = 0L)        # Add column with default value

Tradeoffs of Modify by Reference

  1. Need to keep track of what is referencing the same data
  2. Use copies if you want to keep data independent
  3. When done properly, it can be very memory efficient

What will this do?

pums2 = pums
setnames(pums2, old = "SPORDER", new = "id")

What will this do?

pums2 = pums
setnames(pums2, old = "SPORDER", new = "id")
names(pums)
  [1] "id"         "RT"         "SERIALNO"   "PUMA"       "ST"        
  [6] "ADJUST"     "PWGTP"      "AGEP"       "CIT"        "COW"       
 [11] "DDRS"       "DEYE"       "DOUT"       "DPHY"       "DREM"      
 [16] "DWRK"       "ENG"        "FER"        "GCL"        "GCM"       
 [21] "GCR"        "INTP"       "JWMNP"      "JWRIP"      "JWTR"      
 [26] "LANX"       "MAR"        "MIG"        "MIL"        "MILY"      
 [31] "MLPA"       "MLPB"       "MLPC"       "MLPD"       "MLPE"      
 [36] "MLPF"       "MLPG"       "MLPH"       "MLPI"       "MLPJ"      
 [41] "MLPK"       "NWAB"       "NWAV"       "NWLA"       "NWLK"      
 [46] "NWRE"       "OIP"        "PAP"        "REL"        "RETP"      
 [51] "SCH"        "SCHG"       "SCHL"       "SEMP"       "SEX"       
 [56] "SSIP"       "SSP"        "WAGP"       "WKHP"       "WKL"       
 [61] "WKW"        "YOEP"       "UWRK"       "ANC"        "ANC1P"     
 [66] "ANC2P"      "DECADE"     "DRIVESP"    "DS"         "ESP"       
 [71] "ESR"        "HISP"       "INDP"       "JWAP"       "JWDP"      
 [76] "LANP"       "MIGPUMA"    "MIGSP"      "MSP"        "NAICSP"    
 [81] "NATIVITY"   "OC"         "OCCP"       "PAOC"       "PERNP"     
 [86] "PINCP"      "POBP"       "POVPIP"     "POWPUMA"    "POWSP"     
 [91] "QTRBIR"     "RAC1P"      "RAC2P"      "RAC3P"      "RACAIAN"   
 [96] "RACASN"     "RACBLK"     "RACNHPI"    "RACNUM"     "RACSOR"    
[101] "RACWHT"     "RC"         "SFN"        "SFR"        "SOCP"      
[106] "VPS"        "WAOB"       "FAGEP"      "FANCP"      "FCITP"     
[111] "FCOWP"      "FDDRSP"     "FDEYEP"     "FDOUTP"     "FDPHYP"    
[116] "FDREMP"     "FDWRKP"     "FENGP"      "FESRP"      "FFERP"     
[121] "FGCLP"      "FGCMP"      "FGCRP"      "FHISP"      "FINDP"     
[126] "FINTP"      "FJWDP"      "FJWMNP"     "FJWRIP"     "FJWTRP"    
[131] "FLANP"      "FLANXP"     "FMARP"      "FMIGP"      "FMIGSP"    
[136] "FMILPP"     "FMILSP"     "FMILYP"     "FOCCP"      "FOIP"      
[141] "FPAP"       "FPOBP"      "FPOWSP"     "FRACP"      "FRELP"     
[146] "FRETP"      "FSCHGP"     "FSCHLP"     "FSCHP"      "FSEMP"     
[151] "FSEXP"      "FSSIP"      "FSSP"       "FWAGP"      "FWKHP"     
[156] "FWKLP"      "FWKWP"      "FYOEP"      "PWGTP1"     "PWGTP2"    
[161] "PWGTP3"     "PWGTP4"     "PWGTP5"     "PWGTP6"     "PWGTP7"    
[166] "PWGTP8"     "PWGTP9"     "PWGTP10"    "PWGTP11"    "PWGTP12"   
[171] "PWGTP13"    "PWGTP14"    "PWGTP15"    "PWGTP16"    "PWGTP17"   
[176] "PWGTP18"    "PWGTP19"    "PWGTP20"    "PWGTP21"    "PWGTP22"   
[181] "PWGTP23"    "PWGTP24"    "PWGTP25"    "PWGTP26"    "PWGTP27"   
[186] "PWGTP28"    "PWGTP29"    "PWGTP30"    "PWGTP31"    "PWGTP32"   
[191] "PWGTP33"    "PWGTP34"    "PWGTP35"    "PWGTP36"    "PWGTP37"   
[196] "PWGTP38"    "PWGTP39"    "PWGTP40"    "PWGTP41"    "PWGTP42"   
[201] "PWGTP43"    "PWGTP44"    "PWGTP45"    "PWGTP46"    "PWGTP47"   
[206] "PWGTP48"    "PWGTP49"    "PWGTP50"    "PWGTP51"    "PWGTP52"   
[211] "PWGTP53"    "PWGTP54"    "PWGTP55"    "PWGTP56"    "PWGTP57"   
[216] "PWGTP58"    "PWGTP59"    "PWGTP60"    "PWGTP61"    "PWGTP62"   
[221] "PWGTP63"    "PWGTP64"    "PWGTP65"    "PWGTP66"    "PWGTP67"   
[226] "PWGTP68"    "PWGTP69"    "PWGTP70"    "PWGTP71"    "PWGTP72"   
[231] "PWGTP73"    "PWGTP74"    "PWGTP75"    "PWGTP76"    "PWGTP77"   
[236] "PWGTP78"    "PWGTP79"    "PWGTP80"    "NOP"        "ADJINC"    
[241] "CITWP"      "DEAR"       "DRAT"       "DRATX"      "HINS1"     
[246] "HINS2"      "HINS3"      "HINS4"      "HINS5"      "HINS6"     
[251] "HINS7"      "MARHD"      "MARHM"      "MARHT"      "MARHW"     
[256] "MARHYP"     "DIS"        "HICOV"      "PRIVCOV"    "PUBCOV"    
[261] "FCITWP"     "FDEARP"     "FDRATP"     "FDRATXP"    "FHINS1P"   
[266] "FHINS2P"    "FHINS3P"    "FHINS4P"    "FHINS5P"    "FHINS6P"   
[271] "FHINS7P"    "FMARHDP"    "FMARHMP"    "FMARHTP"    "FMARHWP"   
[276] "FMARHYP"    "WRK"        "FOD1P"      "FOD2P"      "SCIENGP"   
[281] "SCIENGRLP"  "FFODP"      "FHINS3C"    "FHINS4C"    "FHINS5C"   
[286] "RELP"       "FWRKP"      "FDISP"      "FPERNP"     "FPINCP"    
[291] "FPRIVCOVP"  "FPUBCOVP"   "RACNH"      "RACPI"      "SSPA"      
[296] "MLPCD"      "MLPFG"      "FHICOVP"    "DIVISION"   "REGION"    
[301] "HIMRKS"     "JWTRNS"     "RELSHIPP"   "WKWN"       "FHIMRKSP"  
[306] "FJWTRNSP"   "FRELSHIPP"  "FWKWNP"     "MLPIK"      "year"      
[311] "location"   "age_groups" "ins_type"   "age_decade"

What creates a copy besides copy()


  1. When you subset the data (select columns or filter rows)
  2. Change a data.table to a data.frame or tibble
  3. Aggregate or summarizing of the data.table

4. API Lifecycle Management

“I’m not superstitious, but I am a little stitious.”


Stable and backward compatible

Key principles:

  • Backward compatibility maintained
  • New features don’t break existing code
  • Clear deprecation warnings when needed

5. Community

Active development and strong ecosystem

  • New Governance: As part of a NSF grant, new expansive governance
  • GitHub: 3,500+ stars, active issues and PRs
  • CRAN: Over 2,000 reverse dependencies
  • Stack Overflow: 15,000+ questions tagged with data.table
  • Documentation: Comprehensive vignettes and examples
  • Extensions: dtplyr, data.table.express, tidyfast, tidytable, and more
# Getting help
?data.table
vignette("datatable-intro")
browseVignettes("data.table")

6. Feature Rich

Comprehensive data manipulation toolkit

Joins

# Load household data for comparison
household_data <- open_dataset(here::here("data/household")) |>
  filter(year >= 2020, location %in% c("ca", "tx", "ny")) |>
  collect()
setDT(household_data)

# Create state-year summary from household data
household_summary <- household_data[, 
  .(avg_income = mean(HINCP, na.rm = TRUE)), 
  by = .(ST, year)
]

# Join person and household summaries
pums[household_summary, on = c("ST", "year")] # merge(pums, household_summary, by = c("ST", "year"))
            id            RT      SERIALNO   PUMA          ST ADJUST PWGTP
         <int>        <fctr>        <char> <char>      <char>  <int> <int>
      1:     1 Person Record 2021HU0896827  00904 New York/NY     NA   179
      2:     2 Person Record 2021HU0896827  00904 New York/NY     NA   182
      3:     3 Person Record 2021HU0896827  00904 New York/NY     NA   199
      4:     4 Person Record 2021HU0896827  00904 New York/NY     NA   197
      5:     5 Person Record 2021HU0896827  00904 New York/NY     NA   229
     ---                                                                  
1735551:     1 Person Record 2022HU0898646  00800 New York/NY     NA    47
1735552:     1 Person Record 2022HU0898651  00300 New York/NY     NA    20
1735553:     2 Person Record 2022HU0898651  00300 New York/NY     NA    23
1735554:     1 Person Record 2022HU0898700  04104 New York/NY     NA   141
1735555:     1 Person Record 2022HU0898720  03002 New York/NY     NA    55
          AGEP                            CIT
         <int>                         <fctr>
      1:    60 U.S. citizen by naturalization
      2:    40 U.S. citizen by naturalization
      3:    34 U.S. citizen by naturalization
      4:    26 U.S. citizen by naturalization
      5:    20      Born in the United States
     ---                                     
1735551:    76      Born in the United States
1735552:    72      Born in the United States
1735553:    71      Born in the United States
1735554:    67      Born in the United States
1735555:    34      Born in the United States
                                                                                                       COW
                                                                                                    <fctr>
      1:                      Employee of a private not-for-profit, tax-exempt, or charitable organization
      2:                                                                                              <NA>
      3:                      Employee of a private not-for-profit, tax-exempt, or charitable organization
      4: Employee of a private for-profit co. or bus., or of an individual, for wages, salary, commissions
      5: Employee of a private for-profit co. or bus., or of an individual, for wages, salary, commissions
     ---                                                                                                  
1735551:                                                                       Federal government employee
1735552:                                                                                              <NA>
1735553:                                                                                              <NA>
1735554:                    Self-employed in own not incorporated business, professional practice, or farm
1735555: Employee of a private for-profit co. or bus., or of an individual, for wages, salary, commissions
           DDRS   DEYE   DOUT   DPHY   DREM   DWRK       ENG    FER    GCL
         <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl>    <fctr> <lgcl> <lgcl>
      1:  FALSE  FALSE  FALSE  FALSE  FALSE     NA      Well     NA  FALSE
      2:  FALSE  FALSE  FALSE  FALSE  FALSE     NA  Not well  FALSE  FALSE
      3:  FALSE  FALSE  FALSE  FALSE  FALSE     NA      Well     NA  FALSE
      4:  FALSE  FALSE  FALSE  FALSE  FALSE     NA      Well     NA     NA
      5:  FALSE  FALSE  FALSE  FALSE  FALSE     NA      Well     NA     NA
     ---                                                                  
1735551:  FALSE  FALSE  FALSE  FALSE  FALSE     NA      <NA>     NA  FALSE
1735552:  FALSE  FALSE  FALSE  FALSE  FALSE     NA      <NA>     NA  FALSE
1735553:  FALSE  FALSE  FALSE  FALSE  FALSE     NA      <NA>     NA  FALSE
1735554:  FALSE  FALSE  FALSE   TRUE  FALSE     NA Very well     NA  FALSE
1735555:  FALSE  FALSE  FALSE  FALSE  FALSE     NA      <NA>     NA  FALSE
            GCM    GCR  INTP JWMNP  JWRIP   JWTR   LANX
         <fctr> <lgcl> <int> <int> <char> <char> <lgcl>
      1:   <NA>     NA     0    30      1   <NA>   TRUE
      2:   <NA>     NA     0    NA   <NA>   <NA>   TRUE
      3:   <NA>     NA   290    10      1   <NA>   TRUE
      4:   <NA>     NA     0     5      1   <NA>   TRUE
      5:   <NA>     NA     0    12      1   <NA>   TRUE
     ---                                               
1735551:   <NA>     NA     0    27      1   <NA>  FALSE
1735552:   <NA>     NA     0    NA   <NA>   <NA>  FALSE
1735553:   <NA>     NA     0    NA   <NA>   <NA>  FALSE
1735554:   <NA>     NA  3200    NA   <NA>   <NA>   TRUE
1735555:   <NA>     NA  4300     5      1   <NA>  FALSE
                                         MAR    MIG
                                      <fctr> <lgcl>
      1:                             Married   TRUE
      2:                             Married   TRUE
      3: Never married or under 15 years old   TRUE
      4: Never married or under 15 years old   TRUE
      5: Never married or under 15 years old   TRUE
     ---                                           
1735551:                            Divorced   TRUE
1735552:                             Married   TRUE
1735553:                             Married   TRUE
1735554: Never married or under 15 years old   TRUE
1735555:                             Married   TRUE
                                  MIL   MILY   MLPA   MLPB   MLPC   MLPD   MLPE
                               <fctr> <fctr> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl>
      1: Never served in the military   <NA>     NA     NA     NA     NA     NA
      2: Never served in the military   <NA>     NA     NA     NA     NA     NA
      3: Never served in the military   <NA>     NA     NA     NA     NA     NA
      4: Never served in the military   <NA>     NA     NA     NA     NA     NA
      5: Never served in the military   <NA>     NA     NA     NA     NA     NA
     ---                                                                       
1735551: Never served in the military   <NA>     NA     NA     NA     NA     NA
1735552: Never served in the military   <NA>     NA     NA     NA     NA     NA
1735553: Never served in the military   <NA>     NA     NA     NA     NA     NA
1735554: Never served in the military   <NA>     NA     NA     NA     NA     NA
1735555: Never served in the military   <NA>     NA     NA     NA     NA     NA
           MLPF   MLPG   MLPH   MLPI   MLPJ   MLPK   NWAB           NWAV   NWLA
         <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl>         <fctr> <lgcl>
      1:     NA     NA     NA     NA     NA     NA     NA Did not report     NA
      2:     NA     NA     NA     NA     NA     NA  FALSE Did not report  FALSE
      3:     NA     NA     NA     NA     NA     NA     NA Did not report     NA
      4:     NA     NA     NA     NA     NA     NA     NA Did not report     NA
      5:     NA     NA     NA     NA     NA     NA     NA Did not report     NA
     ---                                                                       
1735551:     NA     NA     NA     NA     NA     NA     NA Did not report     NA
1735552:     NA     NA     NA     NA     NA     NA  FALSE Did not report  FALSE
1735553:     NA     NA     NA     NA     NA     NA  FALSE Did not report  FALSE
1735554:     NA     NA     NA     NA     NA     NA  FALSE Did not report  FALSE
1735555:     NA     NA     NA     NA     NA     NA     NA Did not report     NA
           NWLK   NWRE   OIP   PAP    REL  RETP    SCH
         <lgcl> <lgcl> <int> <int> <char> <int> <lgcl>
      1:     NA     NA  3300  3300   <NA>     0  FALSE
      2:  FALSE     NA     0     0   <NA>     0  FALSE
      3:     NA     NA     0     0   <NA>     0  FALSE
      4:     NA     NA     0     0   <NA>     0  FALSE
      5:     NA     NA     0     0   <NA>     0  FALSE
     ---                                              
1735551:     NA     NA     0 21100   <NA> 31800  FALSE
1735552:  FALSE     NA     0     0   <NA>     0  FALSE
1735553:  FALSE     NA     0     0   <NA>     0  FALSE
1735554:  FALSE     NA     0     0   <NA>  1700  FALSE
1735555:     NA     NA     0     0   <NA>     0   TRUE
                                                               SCHG
                                                             <char>
      1:                                                       <NA>
      2:                                                       <NA>
      3:                                                       <NA>
      4:                                                       <NA>
      5:                                                       <NA>
     ---                                                           
1735551:                                                       <NA>
1735552:                                                       <NA>
1735553:                                                       <NA>
1735554:                                                       <NA>
1735555: Graduate or professional school beyond a bachelor's degree
                                       SCHL  SEMP    SEX  SSIP   SSP   WAGP
                                     <char> <int> <fctr> <int> <int>  <int>
      1:                 Associate's degree     0   Male     0     0  68000
      2:        Regular high school diploma     0 Female     0     0      0
      3:                 Associate's degree     0   Male     0     0  36000
      4:        Regular high school diploma     0   Male     0     0  40000
      5:        Regular high school diploma     0   Male     0     0  12000
     ---                                                                   
1735551: Some college, but less than 1 year     0   Male     0 25000  12000
1735552: Some college, but less than 1 year     0   Male     0 24600      0
1735553:        Regular high school diploma     0 Female     0  9300      0
1735554:                    Master's degree     0 Female     0     0      0
1735555:                   Doctorate degree     0   Male     0     0 401000
          WKHP                              WKL    WKW   YOEP   UWRK
         <int>                           <fctr> <fctr> <char> <lgcl>
      1:    40        Within the past 12 months   <NA>   1990     NA
      2:    NA Over 5 years ago or never worked   <NA>   2012     NA
      3:    32        Within the past 12 months   <NA>   2004     NA
      4:    40        Within the past 12 months   <NA>   1998     NA
      5:    30        Within the past 12 months   <NA>   <NA>     NA
     ---                                                            
1735551:    30        Within the past 12 months   <NA>   <NA>     NA
1735552:    NA Over 5 years ago or never worked   <NA>   <NA>     NA
1735553:    NA Over 5 years ago or never worked   <NA>   <NA>     NA
1735554:    NA                    1-5 years ago   <NA>   <NA>     NA
1735555:    70        Within the past 12 months   <NA>   <NA>     NA
                  ANC            ANC1P        ANC2P        DECADE
               <fctr>           <char>       <char>        <fctr>
      1:       Single           Yemeni Not reported   1990 - 1999
      2:       Single           Yemeni Not reported 2010 or later
      3:       Single           Yemeni Not reported   2000 - 2009
      4:       Single           Yemeni Not reported   1990 - 1999
      5:       Single           Yemeni Not reported          <NA>
     ---                                                         
1735551:       Single          Italian Not reported          <NA>
1735552:     Multiple          English        Irish          <NA>
1735553:     Multiple          English        Irish          <NA>
1735554:       Single Eastern European Not reported          <NA>
1735555: Not reported     Not reported Not reported          <NA>
                              DRIVESP     DS    ESP                        ESR
                               <fctr> <lgcl> <fctr>                     <fctr>
      1: 1.000 vehicles (Drove alone)     NA   <NA> Civilian employed, at work
      2:                         <NA>     NA   <NA>         Not in Labor Force
      3: 1.000 vehicles (Drove alone)     NA   <NA> Civilian employed, at work
      4: 1.000 vehicles (Drove alone)     NA   <NA> Civilian employed, at work
      5: 1.000 vehicles (Drove alone)     NA   <NA> Civilian employed, at work
     ---                                                                      
1735551: 1.000 vehicles (Drove alone)     NA   <NA> Civilian employed, at work
1735552:                         <NA>     NA   <NA>         Not in Labor Force
1735553:                         <NA>     NA   <NA>         Not in Labor Force
1735554:                         <NA>     NA   <NA>         Not in Labor Force
1735555: 1.000 vehicles (Drove alone)     NA   <NA> Civilian employed, at work
                                HISP
                              <char>
      1: Not Spanish/Hispanic/Latino
      2: Not Spanish/Hispanic/Latino
      3: Not Spanish/Hispanic/Latino
      4: Not Spanish/Hispanic/Latino
      5: Not Spanish/Hispanic/Latino
     ---                            
1735551: Not Spanish/Hispanic/Latino
1735552: Not Spanish/Hispanic/Latino
1735553: Not Spanish/Hispanic/Latino
1735554: Not Spanish/Hispanic/Latino
1735555: Not Spanish/Hispanic/Latino
                                                                                                                 INDP
                                                                                                               <char>
      1: MED-General Medical And Surgical Hospitals, And Specialty (Except Psychiatric And Substance Abuse) Hospitals
      2:                                                                                                         <NA>
      3:                                                                           SCA-Individual And Family Services
      4:                                                        MFG-Knitting Fabric Mills, And Apparel Knitting Mills
      5:                                               RET-Supermarkets and Other Grocery (Except Convenience) Stores
     ---                                                                                                             
1735551:                                                           RET-Automotive Parts, Accessories, And Tire Stores
1735552:                                                                                                         <NA>
1735553:                                                                                                         <NA>
1735554:                                                PRF-Management, Scientific, And Technical Consulting Services
1735555:                                                                                           PRF-Legal Services
                           JWAP                   JWDP   LANP MIGPUMA  MIGSP
                         <char>                 <char> <char>  <fctr> <char>
      1: 9:00 a.m. to 9:04 a.m. 8:30 a.m. to 8:34 a.m. Arabic    <NA>   <NA>
      2:                   <NA>                   <NA> Arabic    <NA>   <NA>
      3: 8:10 a.m. to 8:14 a.m. 8:00 a.m. to 8:04 a.m. Arabic    <NA>   <NA>
      4: 8:05 a.m. to 8:09 a.m. 8:00 a.m. to 8:04 a.m. Arabic    <NA>   <NA>
      5: 7:10 a.m. to 7:14 a.m. 7:00 a.m. to 7:04 a.m. Arabic    <NA>   <NA>
     ---                                                                    
1735551: 7:55 a.m. to 7:59 a.m. 7:30 a.m. to 7:34 a.m.   <NA>    <NA>   <NA>
1735552:                   <NA>                   <NA>   <NA>    <NA>   <NA>
1735553:                   <NA>                   <NA>   <NA>    <NA>   <NA>
1735554:                   <NA>                   <NA> Hebrew    <NA>   <NA>
1735555: 8:05 a.m. to 8:09 a.m. 8:00 a.m. to 8:04 a.m.   <NA>    <NA>   <NA>
                                 MSP
                              <fctr>
      1: Now Married, Spouse Present
      2: Now Married, Spouse Present
      3:               Never Married
      4:               Never Married
      5:               Never Married
     ---                            
1735551:                    Divorced
1735552: Now Married, Spouse Present
1735553: Now Married, Spouse Present
1735554:               Never Married
1735555: Now Married, Spouse Present
                                                                                                               NAICSP
                                                                                                               <char>
      1: MED-General Medical And Surgical Hospitals, And Specialty (Except Psychiatric And Substance Abuse) Hospitals
      2:                                                                                                         <NA>
      3:                                                                           SCA-Individual And Family Services
      4:                                                        MFG-Knitting Fabric Mills, And Apparel Knitting Mills
      5:                                               RET-Supermarkets And Other Grocery (Except Convenience) Stores
     ---                                                                                                             
1735551:                                                           RET-Automotive Parts, Accessories, And Tire Stores
1735552:                                                                                                         <NA>
1735553:                                                                                                         <NA>
1735554:                                                PRF-Management, Scientific, And Technical Consulting Services
1735555:                                                                                           PRF-Legal Services
             NATIVITY     OC
               <fctr> <lgcl>
      1: Foreign born     NA
      2: Foreign born     NA
      3: Foreign born     NA
      4: Foreign born     NA
      5:       Native     NA
     ---                    
1735551:       Native     NA
1735552:       Native     NA
1735553:       Native     NA
1735554:       Native     NA
1735555:       Native     NA
                                                                                                         OCCP
                                                                                                       <char>
      1:                                                                   EDU-Other Teachers and Instructors
      2:                                                                                                 <NA>
      3:                                                                              HLS-Personal Care Aides
      4:                                                           CON-Other Construction And Related Workers
      5:                                                                       TRN-Stockers And Order Fillers
     ---                                                                                                     
1735551:                                                                                         SAL-Cashiers
1735552:                                                                                                 <NA>
1735553:                                                                                                 <NA>
1735554: SAL-Sales Representatives Of Services, Except Advertising, Insurance, Financial Services, And Travel
1735555:                                     LGL-Lawyers, And Judges, Magistrates, And Other Judicial Workers
                                                 PAOC  PERNP  PINCP
                                               <fctr>  <int>  <int>
      1:                                         <NA>  68000  74600
      2: Females with own children under 6 years only      0      0
      3:                                         <NA>  36000  36290
      4:                                         <NA>  40000  40000
      5:                                         <NA>  12000  12000
     ---                                                           
1735551:                                         <NA>  12000  89900
1735552:                                         <NA>      0  24600
1735553:                 Females with no own children      0   9300
1735554:                 Females with no own children      0   4900
1735555:                                         <NA> 401000 405300
                  POBP POVPIP POWPUMA       POWSP                   QTRBIR
                <char>  <int>  <fctr>      <char>                   <fctr>
      1:         Yemen    386    <NA> New York/NY       April through June
      2:         Yemen    386    <NA>        <NA>    January through March
      3:         Yemen    386    <NA> New York/NY       April through June
      4:         Yemen    386    <NA> New York/NY   July through September
      5:   New York/NY    386    <NA> New York/NY October through December
     ---                                                                  
1735551:   New York/NY    501    <NA> New York/NY October through December
1735552: New Jersey/NJ    205    <NA>        <NA> October through December
1735553:   New York/NY    205    <NA>        <NA>   July through September
1735554:   New York/NY     37    <NA>        <NA>       April through June
1735555: New Jersey/NJ    501    <NA> New York/NY   July through September
               RAC1P       RAC2P       RAC3P RACAIAN RACASN RACBLK RACNHPI
              <fctr>      <char>      <char>  <lgcl> <lgcl> <lgcl>  <lgcl>
      1: White alone White alone White alone   FALSE  FALSE  FALSE      NA
      2: White alone White alone White alone   FALSE  FALSE  FALSE      NA
      3: White alone White alone White alone   FALSE  FALSE  FALSE      NA
      4: White alone White alone White alone   FALSE  FALSE  FALSE      NA
      5: White alone White alone White alone   FALSE  FALSE  FALSE      NA
     ---                                                                  
1735551: White alone White alone White alone   FALSE  FALSE  FALSE      NA
1735552: White alone White alone White alone   FALSE  FALSE  FALSE      NA
1735553: White alone White alone White alone   FALSE  FALSE  FALSE      NA
1735554: White alone White alone White alone   FALSE  FALSE  FALSE      NA
1735555: White alone White alone White alone   FALSE  FALSE  FALSE      NA
         RACNUM RACSOR RACWHT     RC    SFN    SFR
          <int> <lgcl> <lgcl> <lgcl> <fctr> <fctr>
      1:      1  FALSE   TRUE     NA   <NA>   <NA>
      2:      1  FALSE   TRUE     NA   <NA>   <NA>
      3:      1  FALSE   TRUE     NA   <NA>   <NA>
      4:      1  FALSE   TRUE     NA   <NA>   <NA>
      5:      1  FALSE   TRUE     NA   <NA>   <NA>
     ---                                          
1735551:      1  FALSE   TRUE     NA   <NA>   <NA>
1735552:      1  FALSE   TRUE     NA   <NA>   <NA>
1735553:      1  FALSE   TRUE     NA   <NA>   <NA>
1735554:      1  FALSE   TRUE     NA   <NA>   <NA>
1735555:      1  FALSE   TRUE     NA   <NA>   <NA>
                                                                                                         SOCP
                                                                                                       <char>
      1:                                                                   EDU-Other Teachers And Instructors
      2:                                                                                                 <NA>
      3:                                                                              HLS-Personal Care Aides
      4:                                                           CON-Other Construction And Related Workers
      5:                                                                       TRN-Stockers And Order Fillers
     ---                                                                                                     
1735551:                                                                                         SAL-Cashiers
1735552:                                                                                                 <NA>
1735553:                                                                                                 <NA>
1735554: SAL-Sales Representatives Of Services, Except Advertising, Insurance, Financial Services, And Travel
1735555:                                     LGL-Lawyers, And Judges, Magistrates, And Other Judicial Workers
            VPS                              WAOB  FAGEP  FANCP  FCITP  FCOWP
         <char>                            <fctr> <lgcl> <lgcl> <lgcl> <lgcl>
      1:   <NA> Asia (POBP = 158-159,161,200-299)  FALSE  FALSE  FALSE   TRUE
      2:   <NA> Asia (POBP = 158-159,161,200-299)  FALSE  FALSE   TRUE  FALSE
      3:   <NA> Asia (POBP = 158-159,161,200-299)  FALSE  FALSE  FALSE   TRUE
      4:   <NA> Asia (POBP = 158-159,161,200-299)  FALSE  FALSE  FALSE   TRUE
      5:   <NA>         US state (POBP = 001-059)  FALSE  FALSE  FALSE   TRUE
     ---                                                                     
1735551:   <NA>         US state (POBP = 001-059)  FALSE  FALSE  FALSE  FALSE
1735552:   <NA>         US state (POBP = 001-059)  FALSE  FALSE  FALSE  FALSE
1735553:   <NA>         US state (POBP = 001-059)  FALSE  FALSE  FALSE  FALSE
1735554:   <NA>         US state (POBP = 001-059)  FALSE  FALSE  FALSE  FALSE
1735555:   <NA>         US state (POBP = 001-059)  FALSE  FALSE  FALSE   TRUE
         FDDRSP FDEYEP FDOUTP FDPHYP FDREMP FDWRKP  FENGP  FESRP  FFERP  FGCLP
         <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl>
      1:  FALSE  FALSE  FALSE  FALSE  FALSE     NA  FALSE  FALSE  FALSE  FALSE
      2:  FALSE  FALSE  FALSE  FALSE  FALSE     NA  FALSE  FALSE  FALSE  FALSE
      3:  FALSE  FALSE  FALSE  FALSE  FALSE     NA  FALSE  FALSE  FALSE  FALSE
      4:  FALSE  FALSE  FALSE  FALSE  FALSE     NA  FALSE  FALSE  FALSE  FALSE
      5:  FALSE  FALSE  FALSE  FALSE  FALSE     NA  FALSE  FALSE  FALSE  FALSE
     ---                                                                      
1735551:  FALSE  FALSE  FALSE  FALSE  FALSE     NA  FALSE  FALSE  FALSE  FALSE
1735552:  FALSE  FALSE  FALSE  FALSE  FALSE     NA  FALSE  FALSE  FALSE  FALSE
1735553:  FALSE  FALSE  FALSE  FALSE  FALSE     NA  FALSE  FALSE  FALSE  FALSE
1735554:  FALSE  FALSE  FALSE  FALSE  FALSE     NA  FALSE  FALSE  FALSE  FALSE
1735555:   TRUE   TRUE   TRUE   TRUE   TRUE     NA  FALSE   TRUE  FALSE  FALSE
          FGCMP  FGCRP  FHISP  FINDP  FINTP  FJWDP FJWMNP FJWRIP FJWTRP  FLANP
         <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl>
      1:  FALSE  FALSE  FALSE   TRUE   TRUE   TRUE   TRUE   TRUE     NA  FALSE
      2:  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE     NA  FALSE
      3:  FALSE  FALSE  FALSE   TRUE   TRUE   TRUE   TRUE   TRUE     NA  FALSE
      4:  FALSE  FALSE  FALSE   TRUE   TRUE   TRUE   TRUE   TRUE     NA  FALSE
      5:  FALSE  FALSE  FALSE   TRUE   TRUE   TRUE   TRUE   TRUE     NA  FALSE
     ---                                                                      
1735551:  FALSE  FALSE  FALSE  FALSE   TRUE  FALSE  FALSE  FALSE     NA  FALSE
1735552:  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE     NA  FALSE
1735553:  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE     NA  FALSE
1735554:  FALSE  FALSE  FALSE  FALSE   TRUE  FALSE  FALSE  FALSE     NA  FALSE
1735555:  FALSE  FALSE  FALSE   TRUE   TRUE   TRUE   TRUE   TRUE     NA  FALSE
         FLANXP  FMARP  FMIGP FMIGSP FMILPP FMILSP FMILYP  FOCCP   FOIP   FPAP
         <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl>
      1:  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE     NA   TRUE   TRUE   TRUE
      2:  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE     NA  FALSE  FALSE  FALSE
      3:  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE     NA   TRUE   TRUE   TRUE
      4:  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE     NA   TRUE   TRUE   TRUE
      5:  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE     NA   TRUE   TRUE   TRUE
     ---                                                                      
1735551:  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE     NA  FALSE   TRUE   TRUE
1735552:  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE     NA  FALSE  FALSE  FALSE
1735553:  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE     NA  FALSE  FALSE  FALSE
1735554:  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE     NA  FALSE  FALSE  FALSE
1735555:  FALSE  FALSE  FALSE  FALSE  FALSE   TRUE     NA   TRUE   TRUE   TRUE
          FPOBP FPOWSP  FRACP  FRELP  FRETP FSCHGP FSCHLP  FSCHP  FSEMP  FSEXP
         <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl>
      1:  FALSE   TRUE  FALSE     NA   TRUE  FALSE  FALSE  FALSE   TRUE  FALSE
      2:  FALSE  FALSE  FALSE     NA  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE
      3:  FALSE   TRUE  FALSE     NA   TRUE  FALSE  FALSE  FALSE   TRUE  FALSE
      4:  FALSE   TRUE  FALSE     NA   TRUE  FALSE  FALSE  FALSE   TRUE  FALSE
      5:  FALSE   TRUE  FALSE     NA   TRUE  FALSE  FALSE  FALSE   TRUE  FALSE
     ---                                                                      
1735551:  FALSE  FALSE  FALSE     NA   TRUE  FALSE  FALSE  FALSE  FALSE  FALSE
1735552:  FALSE  FALSE  FALSE     NA  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE
1735553:  FALSE  FALSE  FALSE     NA  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE
1735554:  FALSE  FALSE  FALSE     NA  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE
1735555:  FALSE   TRUE  FALSE     NA   TRUE  FALSE  FALSE  FALSE   TRUE  FALSE
          FSSIP   FSSP  FWAGP  FWKHP  FWKLP  FWKWP  FYOEP PWGTP1 PWGTP2 PWGTP3
         <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl>  <int>  <int>  <int>
      1:   TRUE   TRUE   TRUE   TRUE   TRUE     NA  FALSE    266    197     50
      2:  FALSE  FALSE  FALSE  FALSE  FALSE     NA   TRUE    291    172     54
      3:   TRUE   TRUE   TRUE   TRUE   TRUE     NA   TRUE    270    192     54
      4:   TRUE   TRUE   TRUE   TRUE   TRUE     NA   TRUE    311    211     57
      5:   TRUE   TRUE   TRUE   TRUE   TRUE     NA  FALSE    305    237     66
     ---                                                                      
1735551:  FALSE   TRUE  FALSE  FALSE  FALSE     NA  FALSE     81     45     51
1735552:  FALSE  FALSE  FALSE  FALSE  FALSE     NA  FALSE     18     35      6
1735553:  FALSE  FALSE  FALSE  FALSE  FALSE     NA  FALSE     19     42      5
1735554:  FALSE  FALSE  FALSE  FALSE  FALSE     NA  FALSE    240    131    142
1735555:   TRUE   TRUE   TRUE   TRUE   TRUE     NA  FALSE     23     14     14
         PWGTP4 PWGTP5 PWGTP6 PWGTP7 PWGTP8 PWGTP9 PWGTP10 PWGTP11 PWGTP12
          <int>  <int>  <int>  <int>  <int>  <int>   <int>   <int>   <int>
      1:    300    191    287    190     57    152      56     283     170
      2:    322    172    282    197     55    169      57     304     167
      3:    353    228    317    189     59    173      71     294     184
      4:    307    211    274    203     63    159      69     293     189
      5:    466    211    358    235     66    186      95     385     221
     ---                                                                  
1735551:     75     45     14     73     64     12      42      49      15
1735552:     43     23      6      7      5     15      41       8      20
1735553:     45     28      7      6      7     16      49       9      25
1735554:    233    152     45    233    219     46     139     137      43
1735555:     19     96     56     66     22     73      53      58      86
         PWGTP13 PWGTP14 PWGTP15 PWGTP16 PWGTP17 PWGTP18 PWGTP19 PWGTP20
           <int>   <int>   <int>   <int>   <int>   <int>   <int>   <int>
      1:      54      54     177     169     180     197     179      57
      2:      61      57     163     169     184     212     192      58
      3:      63      60     164     179     200     223     218      66
      4:      65      71     187     179     222     198     217      62
      5:      62      76     204     205     249     243     219      79
     ---                                                                
1735551:      48      14      51      44      46      65      46      14
1735552:      22      21      17      40      33      22      22      30
1735553:      27      24      21      50      38      25      24      37
1735554:     131      42     159     146     138     219     150     245
1735555:      60      53      99      43      62      73      77      54
         PWGTP21 PWGTP22 PWGTP23 PWGTP24 PWGTP25 PWGTP26 PWGTP27 PWGTP28
           <int>   <int>   <int>   <int>   <int>   <int>   <int>   <int>
      1:      54     185     280      58     187      59     164     296
      2:      52     190     313      56     176      60     186     275
      3:      60     213     313      76     204      63     186     294
      4:      66     218     278      66     210      67     196     304
      5:      80     230     314      84     226      71     217     389
     ---                                                                
1735551:      84      50      56      89      46      17      81      82
1735552:       4      18      19      20       8      23      18      24
1735553:       5      20      20      22       9      23      21      26
1735554:      44     137     133      41     146     261      43      41
1735555:      16      21      16      14      70      49      59      14
         PWGTP29 PWGTP30 PWGTP31 PWGTP32 PWGTP33 PWGTP34 PWGTP35 PWGTP36
           <int>   <int>   <int>   <int>   <int>   <int>   <int>   <int>
      1:     184     295      56     166     338     295     180     189
      2:     189     290      57     180     332     312     175     180
      3:     225     303      67     224     346     350     213     206
      4:     194     289      74     224     353     322     186     180
      5:     234     343      89     207     358     335     249     257
     ---                                                                
1735551:      15      55      46      12      45      15      57      41
1735552:      37      20      22       6      36       5       6      20
1735553:      37      25      26       6      41       7       5      19
1735554:     245     133     138     262     135     220     139     149
1735555:      87      51      63      88      56      61      84      78
         PWGTP37 PWGTP38 PWGTP39 PWGTP40 PWGTP41 PWGTP42 PWGTP43 PWGTP44
           <int>   <int>   <int>   <int>   <int>   <int>   <int>   <int>
      1:     165     176     174     297     274     159      56     280
      2:     165     179     185     301     272     161      64     268
      3:     172     202     190     298     298     187      59     282
      4:     191     191     180     302     298     200      55     345
      5:     245     230     231     335     388     170      70     353
     ---                                                                
1735551:      50      90      47      88      12      44      42      18
1735552:      18      33      36      20      19       7      29       7
1735553:      22      41      36      22      21       7      36       8
1735554:     145      40     140      45     240     140     140     260
1735555:      53      57     101      72      15      20      15      16
         PWGTP45 PWGTP46 PWGTP47 PWGTP48 PWGTP49 PWGTP50 PWGTP51 PWGTP52
           <int>   <int>   <int>   <int>   <int>   <int>   <int>   <int>
      1:     193     282     164      54     155      56     286     180
      2:     176     276     168      56     180      60     278     198
      3:     214     338     190      60     165      70     287     216
      4:     271     303     194      52     194      68     301     174
      5:     274     374     167      76     211      72     327     203
     ---                                                                
1735551:      50      73      12      19      73      45      50      85
1735552:      23      29      33      37      20       8      38      18
1735553:      28      33      36      47      24       8      45      23
1735554:     153      44     239     247      42     132     142      46
1735555:      87      62      47      14     106      74      53      85
         PWGTP53 PWGTP54 PWGTP55 PWGTP56 PWGTP57 PWGTP58 PWGTP59 PWGTP60
           <int>   <int>   <int>   <int>   <int>   <int>   <int>   <int>
      1:      53      55     178     170     194     196     209      51
      2:      52      56     184     178     207     180     206      52
      3:      66      60     222     191     193     218     225      56
      4:      53      66     184     190     210     196     220      57
      5:      73      66     210     239     266     222     217      66
     ---                                                                
1735551:      55      90      44      49      50      16      41      79
1735552:      20      18      19       7       7      21      19       7
1735553:      21      22      21       6       6      22      20       6
1735554:     134      41     130     132     143     222     148     255
1735555:      46      62      89      69      58      50      96      54
         PWGTP61 PWGTP62 PWGTP63 PWGTP64 PWGTP65 PWGTP66 PWGTP67 PWGTP68
           <int>   <int>   <int>   <int>   <int>   <int>   <int>   <int>
      1:      56     191     308      53     180      55     182     299
      2:      58     192     304      63     194      57     188     316
      3:      64     203     320      63     190      67     212     296
      4:      59     241     316      64     198      59     184     291
      5:      83     271     350      75     245      82     237     385
     ---                                                                
1735551:      13      48      55      14      47      86      16      13
1735552:      31      18      18      20      40      24      22      19
1735553:      35      19      17      25      48      26      25      23
1735554:      45     138     134      42     139     229      41      42
1735555:      16      16      12      14     112      69      51      18
         PWGTP69 PWGTP70 PWGTP71 PWGTP72 PWGTP73 PWGTP74 PWGTP75 PWGTP76
           <int>   <int>   <int>   <int>   <int>   <int>   <int>   <int>
      1:     193     270      57     190     303     311     171     176
      2:     189     291      54     189     306     295     172     170
      3:     240     265      57     220     307     339     217     207
      4:     216     310      60     208     309     412     197     168
      5:     225     331      80     247     355     426     224     217
     ---                                                                
1735551:      73      50      51      89      42      68      47      47
1735552:       5      20      15      36       9      44      34      20
1735553:       6      23      18      40      10      47      38      23
1735554:     261     122     143     243     152     241     142     134
1735555:      99      56      56     106      56      56      94      40
         PWGTP77 PWGTP78 PWGTP79 PWGTP80    NOP   ADJINC  CITWP   DEAR   DRAT
           <int>   <int>   <int>   <int> <fctr>    <num> <char> <lgcl> <fctr>
      1:     181     179     178     305   <NA> 1.029928   2007  FALSE   <NA>
      2:     185     171     185     283   <NA> 1.029928   2018  FALSE   <NA>
      3:     225     192     201     322   <NA> 1.029928   2014  FALSE   <NA>
      4:     218     240     194     265   <NA> 1.029928   2005  FALSE   <NA>
      5:     264     252     212     316   <NA> 1.029928   <NA>  FALSE   <NA>
     ---                                                                     
1735551:      41      15      44      16   <NA> 1.042311   <NA>  FALSE   <NA>
1735552:      17       6       5      20   <NA> 1.042311   <NA>  FALSE   <NA>
1735553:      20       7       7      23   <NA> 1.042311   <NA>  FALSE   <NA>
1735554:     138      40     146      39   <NA> 1.042311   <NA>  FALSE   <NA>
1735555:      53      54      84      45   <NA> 1.042311   <NA>  FALSE   <NA>
          DRATX  HINS1  HINS2  HINS3  HINS4  HINS5  HINS6  HINS7  MARHD  MARHM
         <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl> <lgcl>
      1:     NA  FALSE   TRUE  FALSE   TRUE  FALSE  FALSE  FALSE  FALSE  FALSE
      2:     NA  FALSE   TRUE  FALSE   TRUE  FALSE  FALSE  FALSE  FALSE  FALSE
      3:     NA  FALSE   TRUE  FALSE  FALSE  FALSE  FALSE  FALSE     NA     NA
      4:     NA  FALSE   TRUE  FALSE  FALSE  FALSE  FALSE  FALSE     NA     NA
      5:     NA  FALSE   TRUE  FALSE  FALSE  FALSE  FALSE  FALSE     NA     NA
     ---                                                                      
1735551:     NA   TRUE  FALSE   TRUE  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE
1735552:     NA  FALSE   TRUE   TRUE  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE
1735553:     NA  FALSE   TRUE   TRUE  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE
1735554:     NA  FALSE  FALSE   TRUE  FALSE  FALSE  FALSE  FALSE     NA     NA
1735555:     NA   TRUE  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE  FALSE
                       MARHT  MARHW MARHYP    DIS  HICOV PRIVCOV PUBCOV FCITWP
                      <fctr> <lgcl> <char> <lgcl> <lgcl>  <lgcl> <lgcl> <lgcl>
      1:            One time  FALSE   2009  FALSE   TRUE    TRUE   TRUE  FALSE
      2:            One time  FALSE   2009  FALSE   TRUE    TRUE   TRUE   TRUE
      3:                <NA>     NA   <NA>  FALSE   TRUE    TRUE  FALSE   TRUE
      4:                <NA>     NA   <NA>  FALSE   TRUE    TRUE  FALSE  FALSE
      5:                <NA>     NA   <NA>  FALSE   TRUE    TRUE  FALSE  FALSE
     ---                                                                      
1735551:            One time  FALSE   1986  FALSE   TRUE    TRUE   TRUE  FALSE
1735552: Three or more times  FALSE   2014  FALSE   TRUE    TRUE   TRUE  FALSE
1735553:           Two Times  FALSE   2014  FALSE   TRUE    TRUE   TRUE  FALSE
1735554:                <NA>     NA   <NA>   TRUE   TRUE   FALSE   TRUE  FALSE
1735555:            One time  FALSE   2019  FALSE   TRUE    TRUE  FALSE  FALSE
         FDEARP FDRATP FDRATXP FHINS1P FHINS2P FHINS3P FHINS4P FHINS5P FHINS6P
         <lgcl> <lgcl>  <lgcl>  <lgcl>  <lgcl>  <lgcl>  <lgcl>  <lgcl>  <lgcl>
      1:  FALSE  FALSE   FALSE   FALSE   FALSE   FALSE   FALSE   FALSE   FALSE
      2:  FALSE  FALSE   FALSE   FALSE   FALSE   FALSE   FALSE   FALSE   FALSE
      3:  FALSE  FALSE   FALSE   FALSE   FALSE   FALSE   FALSE   FALSE   FALSE
      4:  FALSE  FALSE   FALSE   FALSE   FALSE   FALSE   FALSE   FALSE   FALSE
      5:  FALSE  FALSE   FALSE   FALSE   FALSE   FALSE   FALSE   FALSE   FALSE
     ---                                                                      
1735551:  FALSE  FALSE   FALSE   FALSE   FALSE    TRUE   FALSE   FALSE   FALSE
1735552:  FALSE  FALSE   FALSE    TRUE   FALSE   FALSE    TRUE    TRUE    TRUE
1735553:  FALSE  FALSE   FALSE    TRUE   FALSE   FALSE    TRUE    TRUE    TRUE
1735554:  FALSE  FALSE   FALSE   FALSE   FALSE   FALSE   FALSE   FALSE   FALSE
1735555:  FALSE  FALSE   FALSE    TRUE    TRUE    TRUE    TRUE    TRUE    TRUE
         FHINS7P FMARHDP FMARHMP FMARHTP FMARHWP FMARHYP    WRK
          <lgcl>  <lgcl>  <lgcl>  <lgcl>  <lgcl>  <lgcl> <lgcl>
      1:   FALSE   FALSE   FALSE    TRUE   FALSE    TRUE   TRUE
      2:   FALSE   FALSE   FALSE    TRUE   FALSE    TRUE  FALSE
      3:   FALSE   FALSE   FALSE   FALSE   FALSE   FALSE   TRUE
      4:   FALSE   FALSE   FALSE   FALSE   FALSE   FALSE   TRUE
      5:   FALSE   FALSE   FALSE   FALSE   FALSE   FALSE   TRUE
     ---                                                       
1735551:   FALSE   FALSE   FALSE   FALSE   FALSE   FALSE   TRUE
1735552:    TRUE   FALSE   FALSE   FALSE   FALSE   FALSE  FALSE
1735553:    TRUE   FALSE   FALSE   FALSE   FALSE   FALSE  FALSE
1735554:   FALSE   FALSE   FALSE   FALSE   FALSE   FALSE  FALSE
1735555:    TRUE    TRUE    TRUE    TRUE    TRUE    TRUE     NA
                                    FOD1P
                                   <char>
      1:                             <NA>
      2:                             <NA>
      3:                             <NA>
      4:                             <NA>
      5:                             <NA>
     ---                                 
1735551:                             <NA>
1735552:                             <NA>
1735553:                             <NA>
1735554:             Elementary Education
1735555: Marketing And Marketing Research
                                          FOD2P SCIENGP SCIENGRLP  FFODP
                                         <char>  <lgcl>    <lgcl> <lgcl>
      1:                                   <NA>      NA        NA  FALSE
      2:                                   <NA>      NA        NA  FALSE
      3:                                   <NA>      NA        NA  FALSE
      4:                                   <NA>      NA        NA  FALSE
      5:                                   <NA>      NA        NA  FALSE
     ---                                                                
1735551:                                   <NA>      NA        NA  FALSE
1735552:                                   <NA>      NA        NA  FALSE
1735553:                                   <NA>      NA        NA  FALSE
1735554:                Special Needs Education   FALSE     FALSE  FALSE
1735555: Business Management And Administration   FALSE     FALSE   TRUE
         FHINS3C FHINS4C FHINS5C   RELP  FWRKP  FDISP FPERNP FPINCP FPRIVCOVP
          <fctr>  <fctr>  <fctr> <char> <lgcl> <lgcl> <lgcl> <lgcl>    <lgcl>
      1:    <NA>     Yes    <NA>   <NA>  FALSE  FALSE   TRUE   TRUE     FALSE
      2:    <NA>     Yes    <NA>   <NA>  FALSE  FALSE  FALSE  FALSE     FALSE
      3:    <NA>    <NA>    <NA>   <NA>  FALSE  FALSE   TRUE   TRUE     FALSE
      4:    <NA>    <NA>    <NA>   <NA>  FALSE  FALSE   TRUE   TRUE     FALSE
      5:    <NA>    <NA>    <NA>   <NA>  FALSE  FALSE   TRUE   TRUE     FALSE
     ---                                                                     
1735551:     Yes    <NA>    <NA>   <NA>  FALSE  FALSE  FALSE   TRUE     FALSE
1735552:      No    <NA>    <NA>   <NA>  FALSE  FALSE  FALSE  FALSE      TRUE
1735553:      No    <NA>    <NA>   <NA>  FALSE  FALSE  FALSE  FALSE      TRUE
1735554:      No    <NA>    <NA>   <NA>  FALSE  FALSE  FALSE   TRUE     FALSE
1735555:    <NA>    <NA>    <NA>   <NA>  FALSE   TRUE   TRUE   TRUE      TRUE
         FPUBCOVP  RACNH  RACPI   SSPA  MLPCD  MLPFG FHICOVP
           <lgcl> <lgcl> <lgcl> <fctr> <lgcl> <lgcl>  <lgcl>
      1:    FALSE  FALSE  FALSE   <NA>     NA     NA   FALSE
      2:    FALSE  FALSE  FALSE   <NA>     NA     NA   FALSE
      3:    FALSE  FALSE  FALSE   <NA>     NA     NA   FALSE
      4:    FALSE  FALSE  FALSE   <NA>     NA     NA   FALSE
      5:    FALSE  FALSE  FALSE   <NA>     NA     NA   FALSE
     ---                                                    
1735551:     TRUE  FALSE  FALSE   <NA>     NA     NA    TRUE
1735552:     TRUE  FALSE  FALSE   <NA>     NA     NA    TRUE
1735553:     TRUE  FALSE  FALSE   <NA>     NA     NA    TRUE
1735554:    FALSE  FALSE  FALSE   <NA>     NA     NA   FALSE
1735555:     TRUE  FALSE  FALSE   <NA>     NA     NA    TRUE
                                   DIVISION    REGION
                                     <fctr>    <fctr>
      1: Middle Atlantic (Northeast region) Northeast
      2: Middle Atlantic (Northeast region) Northeast
      3: Middle Atlantic (Northeast region) Northeast
      4: Middle Atlantic (Northeast region) Northeast
      5: Middle Atlantic (Northeast region) Northeast
     ---                                             
1735551: Middle Atlantic (Northeast region) Northeast
1735552: Middle Atlantic (Northeast region) Northeast
1735553: Middle Atlantic (Northeast region) Northeast
1735554: Middle Atlantic (Northeast region) Northeast
1735555: Middle Atlantic (Northeast region) Northeast
                                                      HIMRKS             JWTRNS
                                                      <fctr>             <char>
      1:      Direct purchase coverage, with premium subsidy Car, truck, or van
      2: Direct purchase coverage, without a premium subsidy               <NA>
      3:      Direct purchase coverage, with premium subsidy Car, truck, or van
      4: Direct purchase coverage, without a premium subsidy Car, truck, or van
      5: Direct purchase coverage, without a premium subsidy Car, truck, or van
     ---                                                                       
1735551:                Categorically ineligible for subsidy Car, truck, or van
1735552: Direct purchase coverage, without a premium subsidy               <NA>
1735553: Direct purchase coverage, without a premium subsidy               <NA>
1735554:                Categorically ineligible for subsidy               <NA>
1735555:                Categorically ineligible for subsidy Car, truck, or van
                                 RELSHIPP  WKWN FHIMRKSP FJWTRNSP FRELSHIPP
                                   <char> <int>   <lgcl>   <lgcl>    <lgcl>
      1:                 Reference person    52     TRUE     TRUE     FALSE
      2: Opposite-sex husband/wife/spouse    NA     TRUE    FALSE     FALSE
      3:       Biological son or daughter    52     TRUE     TRUE     FALSE
      4:       Biological son or daughter    52     TRUE     TRUE     FALSE
      5:       Biological son or daughter    52     TRUE     TRUE     FALSE
     ---                                                                   
1735551:                 Reference person    52    FALSE    FALSE     FALSE
1735552:                 Reference person    NA    FALSE    FALSE     FALSE
1735553: Opposite-sex husband/wife/spouse    NA    FALSE    FALSE     FALSE
1735554:                 Reference person    NA    FALSE    FALSE     FALSE
1735555:                 Reference person    52    FALSE     TRUE     FALSE
         FWKWNP  MLPIK  year location age_groups ins_type age_decade avg_income
         <lgcl> <lgcl> <int>   <char>     <char>   <char>      <num>      <num>
      1:   TRUE     NA  2021       ny      18-64   direct         60   109935.7
      2:  FALSE     NA  2021       ny      18-64   direct         40   109935.7
      3:   TRUE     NA  2021       ny      18-64   direct         30   109935.7
      4:   TRUE     NA  2021       ny      18-64   direct         20   109935.7
      5:   TRUE     NA  2021       ny      18-64   direct         20   109935.7
     ---                                                                       
1735551:  FALSE     NA  2022       ny        65+ employer         70   116834.5
1735552:  FALSE     NA  2022       ny        65+   direct         70   116834.5
1735553:  FALSE     NA  2022       ny        65+   direct         70   116834.5
1735554:  FALSE     NA  2022       ny        65+ Medicare         60   116834.5
1735555:   TRUE     NA  2022       ny      18-64 employer         30   116834.5

Feature Rich

Reshaping

# Pivot longer - select key demographics
pums_long <- melt(
  pums, 
  id.vars = c("ST", "year", "SERIALNO"),
  measure.vars = c("AGEP", "PWGTP", "PINCP")
)
pums_long
                  ST  year      SERIALNO variable value
              <char> <int>        <char>   <fctr> <int>
      1: New York/NY  2021 2021HU0896827     AGEP    60
      2: New York/NY  2021 2021HU0896827     AGEP    40
      3: New York/NY  2021 2021HU0896827     AGEP    34
      4: New York/NY  2021 2021HU0896827     AGEP    26
      5: New York/NY  2021 2021HU0896827     AGEP    20
     ---                                               
5206661:    Texas/TX  2022 2022HU0609672    PINCP 27600
5206662:    Texas/TX  2022 2022HU0609672    PINCP 50000
5206663:    Texas/TX  2022 2022HU0609672    PINCP 18000
5206664:    Texas/TX  2022 2022HU0609675    PINCP 33700
5206665:    Texas/TX  2022 2022HU0609675    PINCP 42200
# Pivot wider - average by state/year
pums_summary <- pums[, 
  .(avg_age = mean(AGEP, na.rm = TRUE),
    avg_income = mean(PINCP, na.rm = TRUE)), 
  by = .(ST, year)
]
dcast(pums_summary, ST ~ year, value.var = "avg_age")
Key: <ST>
              ST     2021     2022
          <char>    <num>    <num>
1: California/CA 41.47709 41.54009
2:   New York/NY 43.12366 43.18311
3:      Texas/TX 40.59856 40.82080

Feature Rich

Rolling operations

# Population change over time by state
pums_yearly <- pums[, .(pop = sum(PWGTP)), by = .(ST, year)]
setkey(pums_yearly, ST, year)

# Calculate 2-year rolling average (limited years available)
pums_yearly[, pop_2yr_avg := frollmean(pop, 2), by = ST]
pums_yearly
Key: <ST, year>
              ST  year      pop pop_2yr_avg
          <char> <int>    <int>       <num>
1: California/CA  2021 39237836          NA
2: California/CA  2022 39029342    39133589
3:   New York/NY  2021 19835913          NA
4:   New York/NY  2022 19677151    19756532
5:      Texas/TX  2021 29527941          NA
6:      Texas/TX  2022 30029572    29778756

Feature Rich

Rolling Joins

benefit_thresholds <- data.table(
  age_threshold = c(18, 25, 35, 50, 62, 67),
  benefit_type = c("Youth", "Young Adult", "Adult", "Mid-Career", "Pre-Retirement", "Senior"),
  max_benefit = c(500, 800, 1200, 1500, 2000, 2500)
)
setkey(benefit_thresholds, age_threshold)
benefit_thresholds
Key: <age_threshold>
   age_threshold   benefit_type max_benefit
           <num>         <char>       <num>
1:            18          Youth         500
2:            25    Young Adult         800
3:            35          Adult        1200
4:            50     Mid-Career        1500
5:            62 Pre-Retirement        2000
6:            67         Senior        2500

. . .

# Rolling join to assign benefits based on nearest age threshold
pums[
  benefit_thresholds, 
  benefit_category := benefit_type, 
  on = .(AGEP = age_threshold), 
  roll = -Inf
]
pums[, .(AGEP, benefit_category, ins_type, location)]
          AGEP benefit_category ins_type location
         <int>           <char>   <char>   <char>
      1:    60             <NA>   direct       ny
      2:    40             <NA>   direct       ny
      3:    34             <NA>   direct       ny
      4:    26             <NA>   direct       ny
      5:    20             <NA>   direct       ny
     ---                                         
1735551:    56             <NA> employer       tx
1735552:    67           Senior employer       tx
1735553:    21             <NA>   direct       tx
1735554:    66             <NA> employer       tx
1735555:    64             <NA> employer       tx

roll = "nearest" or roll = +Inf are also possible

Feature Rich

Operators - Core Symbols

Essential data.table operators for efficient data manipulation

# .N - Number of rows in each group
pums[, .N, by = ST]  # Count rows by state
              ST      N
          <char>  <int>
1:   New York/NY 403958
2:      Texas/TX 554365
3: California/CA 777232
# .SD - Subset of Data (all columns except grouping)
pums[, names(.SD) := lapply(.SD, mean, na.rm = TRUE), by = ST, .SDcols = c("AGEP", "PINCP")]
pums[, .(ST, AGEP, PINCP)]
                  ST  AGEP PINCP
              <char> <int> <int>
      1: New York/NY    43 52025
      2: New York/NY    43 52025
      3: New York/NY    43 52025
      4: New York/NY    43 52025
      5: New York/NY    43 52025
     ---                        
1735551:    Texas/TX    40 45756
1735552:    Texas/TX    40 45756
1735553:    Texas/TX    40 45756
1735554:    Texas/TX    40 45756
1735555:    Texas/TX    40 45756
# .BY - List of grouping variables
pums[, .(mean_age = mean(AGEP), state = gsub("/.*$", "", .BY)), by = ST]
              ST mean_age      state
          <char>    <num>     <char>
1:   New York/NY       43   New York
2:      Texas/TX       40      Texas
3: California/CA       41 California
# .I - Row indices 
pums[, .I[which.max(AGEP)], by = ST]  # Index of oldest person per state
              ST     V1
          <char>  <int>
1:   New York/NY      1
2:      Texas/TX 200068
3: California/CA 461514

Feature Rich

Operators - Advanced Features

Specialized operators for complex operations

# .EACHI - For each item in i (useful with joins)
household_summary[pums, on = .(ST, year), mean(AGEP), by = .EACHI]
                  ST  year    V1
              <char> <int> <num>
      1: New York/NY  2021    43
      2: New York/NY  2021    43
      3: New York/NY  2021    43
      4: New York/NY  2021    43
      5: New York/NY  2021    43
     ---                        
1735551:    Texas/TX  2022    40
1735552:    Texas/TX  2022    40
1735553:    Texas/TX  2022    40
1735554:    Texas/TX  2022    40
1735555:    Texas/TX  2022    40
# .GRP - Group counter (1, 2, 3, ...)
pums[, .(grp_num = .GRP, pop = sum(PWGTP)), by = ST]
              ST grp_num      pop
          <char>   <int>    <int>
1:   New York/NY       1 39513064
2:      Texas/TX       2 59557513
3: California/CA       3 78267178
# Multiple .SD operations with .SDcols
pums[, {
    means <- lapply(.SD, mean, na.rm = TRUE)
    medians <- lapply(.SD, median, na.rm = TRUE)
    vars <- names(.SD)
    .(vars, means, medians)
  }, 
  by = ST, 
  .SDcols = c("AGEP", "PINCP", "PWGTP")
]
              ST   vars    means medians
          <char> <char>   <list>  <list>
1:   New York/NY   AGEP       43      43
2:   New York/NY  PINCP    52025   52025
3:   New York/NY  PWGTP 97.81478      73
4:      Texas/TX   AGEP       40      40
5:      Texas/TX  PINCP    45756   45756
6:      Texas/TX  PWGTP 107.4338      76
7: California/CA   AGEP       41      41
8: California/CA  PINCP    54155   54155
9: California/CA  PWGTP 100.6999      75
# Chaining with operators
pums[year == 2022][, .N, by = ST][order(-N)]
              ST      N
          <char>  <int>
1: California/CA 391171
2:      Texas/TX 292919
3:   New York/NY 203891

Feature Rich

Not convinced by the syntax?

library(dtplyr)

pums_dt <- pums |> 
  lazy_dt() |> 
  select(PINCP, age_groups, year) |> 
  group_by(age_groups, year) |> 
  summarise(avg_tot_income = mean(PINCP)) |> 
  collect()  # or as.data.table() will collect it too
pums_dt
# A tibble: 6 × 3
# Groups:   age_groups [3]
  age_groups  year avg_tot_income
  <chr>      <int>          <dbl>
1 18-64       2021         51100.
2 18-64       2022         50939.
3 65+         2021         51131.
4 65+         2022         50953.
5 Under 18    2021         50873.
6 Under 18    2022         50701.
pums |> 
  lazy_dt() |> 
  select(PINCP, age_groups, year) |> 
  group_by(age_groups, year) |> 
  summarise(avg_tot_income = mean(PINCP)) |> 
  show_query()
`_DT2`[, .(PINCP, age_groups, year)][, .(avg_tot_income = mean(PINCP)), 
    keyby = .(age_groups, year)]

Review

  1. Learn the DT[i, j, by] syntax - it’s the foundation
  2. Use keys for fast subsetting and joins
  3. Modify by reference with := for memory efficiency
  4. Chain operations and use operators for readable, efficient code
  5. Check the documentation - excellent vignettes available

Resources:

  • Official vignettes: vignette("datatable-intro")
  • GitHub: https://github.com/Rdatatable/data.table
  • Stack Overflow: [data.table] tag